Asynchronous socket problems in windows service
-
Hi, We've wrote an app that utilizes asynchronous sockets to collect real-time information and write it into the database. We are using a slightly modified version of this example: http://www.codeproject.com/csharp/socketsincs.asp for our socket component. Our app works fine, we've been testing it for a week and a half now and it performs almost flawlessly. The problem is that we also need a windows service version of the app, we've completed the windows service a week ago but for some reason it won't work. I've tracked it down and it turns out the BeginConnect call does not work. It just won't connect to the server and therefore no socket is created. m_sock.Blocking = false; AsyncCallback _connect = new AsyncCallback(ConnectServer); m_sock.BeginConnect( epServer, _connect, m_sock ); ConnectServer should return IAsyncResult ar from which we can derive a socket, however it does not work. BeginConnect call fails and service simply fails to establish a connection. Now with the exception of couple of lines specific to the app, the code in the app and in the service is absolutely identical, yet the app works absolutely fine and the service does not. We have no idea what is wrong with the service, why it won't establish connection. We've tried running the service under the domain administrator account thinking it was security issue, but it still won't work. Anyone has any idea what's wrong here? I'm at a complete loss, been searching google for several days now to no avail.
-
Hi, We've wrote an app that utilizes asynchronous sockets to collect real-time information and write it into the database. We are using a slightly modified version of this example: http://www.codeproject.com/csharp/socketsincs.asp for our socket component. Our app works fine, we've been testing it for a week and a half now and it performs almost flawlessly. The problem is that we also need a windows service version of the app, we've completed the windows service a week ago but for some reason it won't work. I've tracked it down and it turns out the BeginConnect call does not work. It just won't connect to the server and therefore no socket is created. m_sock.Blocking = false; AsyncCallback _connect = new AsyncCallback(ConnectServer); m_sock.BeginConnect( epServer, _connect, m_sock ); ConnectServer should return IAsyncResult ar from which we can derive a socket, however it does not work. BeginConnect call fails and service simply fails to establish a connection. Now with the exception of couple of lines specific to the app, the code in the app and in the service is absolutely identical, yet the app works absolutely fine and the service does not. We have no idea what is wrong with the service, why it won't establish connection. We've tried running the service under the domain administrator account thinking it was security issue, but it still won't work. Anyone has any idea what's wrong here? I'm at a complete loss, been searching google for several days now to no avail.
LOCAL SERVICE user account, which is the default for services, does not allow network access. Set your service to run under the NETWORK SERVICE account or ADMINISTRATOR.
-
LOCAL SERVICE user account, which is the default for services, does not allow network access. Set your service to run under the NETWORK SERVICE account or ADMINISTRATOR.