Serial Communications in ASP.NET

G

Guest

Hi All,

I've written an ASP.NET application (webservice) that does simple serial
communications via the .NET 2.0 SerialComm object.

The application runs fine on my development machine. The problem is when we
try to deploy it to another machine we receive: ACCESS IS DENIED TO COM1 PORT.

We have tried unsuccessfully to get this to work. We have tried the following:
1) Assign the IUSR.... account to Administrators
2) We have actually had the local administrator account run the webservice
3) rebooted
4) stopped and restarted IIS - etc. etc.

We are unable to resolve this. Is there a special permission that the
account needs? Once again we are running XP Pro and it works fine in
development but we can't get it to run on this other machine!!!!

Also - we have implemented the same code using a regular client application
and it works fine (i.e. copied all the code out and put it in a simple
windows form and we're fine).

The problem is running it as a webservice. It does not work!

Any thoughts - comments are appreciated! Thanks!
 
G

Greg Young

Your app is running as ASPNET not IUSR_ if I remember correctly. You can
change the user that the application pool that the application runs in. I
would however re-think your architecture as a webserver has no business
being connected to a serial port. I might make a remoting service that
handles the serial port then make a webservice front end.

Cheers,

Greg Young
MVP - C#
http://geekswithblogs.net/gyoung
 
G

Guest

Greg - what do you mean by "...I would however re-think your architecture
as a webserver has no business being connected to a serial port..."? I have
no idea of what you are talking about. If you call up VS 2005 - WebForms -
the SerialPort component is there waiting to be used. Why not use it? Also -
I have found many code examples illustrating exactly what I am successfully
doing already. And they're using ASP.NET. I don't understand this and I feel
embarassed...

I am just having troubles with the communications part of this.

--
Franklin M. Gauer III

Greg Young said:
Your app is running as ASPNET not IUSR_ if I remember correctly. You can
change the user that the application pool that the application runs in. I
would however re-think your architecture as a webserver has no business
being connected to a serial port. I might make a remoting service that
handles the serial port then make a webservice front end.

Cheers,

Greg Young
MVP - C#
http://geekswithblogs.net/gyoung
 
G

Guest

I'm sorry - I'm having troubles with the permissions part...

--
Franklin M. Gauer III



Franklin M. Gauer III said:
Greg - what do you mean by "...I would however re-think your architecture
as a webserver has no business being connected to a serial port..."? I have
no idea of what you are talking about. If you call up VS 2005 - WebForms -
the SerialPort component is there waiting to be used. Why not use it? Also -
I have found many code examples illustrating exactly what I am successfully
doing already. And they're using ASP.NET. I don't understand this and I feel
embarassed...

I am just having troubles with the communications part of this.
 
G

Greg Young

Which part on the permissions?

As for my architecture comment.

The SerialPort would be owned by a single ASP.NET worker process
http://www.codeproject.com/aspnet/aspwp.asp (it would in fact belong to a
single app domain).. you could therefor only ever have a single ASP.NET
worker process... You could not scale yourself to support multiple worker
processes (let alone multiple web servers). You could not for instance run
with an application pool setup to use 10 worker processes (1 would work and
then 9 would fail to open the serial port).

As a rule of thumb, it is best to keep resources like this out of your web
processes as you can then scale the web processes.

http://www.microsoft.com/downloads/...E-4E72-B531-75384A0F1C47&displayLang=en&oRef=
is a useful document .. see "Resource Affinity" in chapter 6.

A perfect example of where this could kill your performance would be the
case where you are polling for a set of data that could be accessed throguh
your webservice via some data methods and exposed a few methods that caused
data to be executed accross the port. By moving the serial port out of the
web process you could feasably have 50 webservers using the same serial port
(in a case where they were mostly having people ask for data methods that
would simply hit their local cache this would in fact be a great
architecture).

The other problem I see alot of with this type of setup is that the ASP.NET
worker processes prefer to restart themselves occasionally. By placing the
serial port code in the web app you miss any polling etc over that port that
would need to be done during this period of time.

The last problem I see, you have already run into. Your code must run in at
an elevated privilege level which opens up far more sruface area for
possible attacks on your system (as opposed to a small component running
with elevated privs your entire app must now run with elevated privs or you
must take other measures within your application to only run certain areas
with elevated permissions). Doing something like making the ASPNET_WP
account an administrator on your system is certainly bad.

Have you tried to get the current identity to see who you are running as?

Cheers,

Greg Young
MVP - C#
http://geekswithblogs.net/gyoung
 
G

Guest

Thanks Greg for your clarifications. This has helped me out tremendously. I
appreciate it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top