views:

98

answers:

2

I have created a Datasnap service, using Bob Swart's white paper as a guide. I have been debugging and deployed succesfully using the VCL Forms application as a server. But when I try to deploy the service version, it installs ok, I then try to start the service and it immediately stops. The error in the event log would suggest that the port set is already in use, I have tried different port numbers for both the TCPServerTransport and the HTTPService without any joy. The DSServer is not set to Autostart as I want to set the Port number from a configuration file. The error message displayed in the event log is:

Service failed on start: Could not bind socket. Address and port are already in use..

I have also tried writing to a log file on start up and execute but it looks as if it is not getting this far.

Solution needed asap, before I have to revert back to a thick client which I do not really want to do.

Thanks

A: 

If you are sure that the port you have configured is actually free and not in use by any other software on the machine, then there might be some anti-virus / security software running that is blocking all software from listening on either specific ports or on any port except a few configured ones. The message you are getting could be one of the symptoms of how the anti-virus / security software handles attempts by apps to start listening on a port.

Marjan Venema
If it is the anti-virus or firewall, then he should face the same problem in his VCL form application too.
vcldeveloper
@vcldeveloper: you are quite right if he used both apps on the same machine. The word "deploy" made me think he might be trying to deploy the service version on a different one.
Marjan Venema
+1  A: 

Firstly get a copy of TCPView from the Sysinternals suite (now run by Microsoft) and use it to monitor which app is using the port you want to use.

I would hazard a guess that if the app works fine as a stand alone (as you say it does) and you are trying to use the same port in the service then perhaps the service app is opening up the port at startup without you realizing it and then when you try to open the port manually the app finds it already in use. Or somehow the app is trying to open the port twice. The first time is successful but, maybe due to an event or an unexpected code path, the app tries to open it a second time and fails. TCPView will help spot this.

shunty
+1 for "the app tries to open it a second time and fails". Netstat alone can be used to check open ports.
Cosmin Prund
True, but TCPView is just so handy in its own right - and you don't need to remember any command line params :-) Plus a 'live' view /might/ be more useful in this situation.
shunty
That solved it, it seems that the problem was with having the project open in the IDE. The DSServer was not set to Autostart but I suspect as I was still developing and testing the server side of the application. I recompiled putting back the code for the start event and then made sure I closed the project in the IDE before starting the service. All worked successfully, fingers crossed for the deployment on my test server! Thanks :)
Matt
Can't say I've ever made that mistake... oh no... course not :-)
shunty