Reputation: 515
So i have a service that i created that checks in with a server every x mins and receives a reply from it. The reply is either a sleep or command. receiving a scan command the service packs up and Tars a load of files and sends them off to the server. During Debug mode my app runs perfectly fine. I can step through the code and everything is being triggered as it should and the communication between client and server is perfectly fine.
However. Upon deployment of my service, it will crash upon receiving a scan command. I have looked at the windows Event Viewer and found this:
Application: Client.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info:
System.Net.WebException Stack: at
System.Net.FtpWebRequest.GetRequestStream() at
tcpClient.ftpClass.upload(System.String, System.String) at
Client.Service1.checkInCycle(System.String) at
Client.Service1.Callback(System.Object) at
System.Threading.TimerQueueTimer.CallCallbackInContext(System.Object) at
System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext,
System.Threading.ContextCallback, System.Object, Boolean) at
System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext,
System.Threading.ContextCallback, System.Object, Boolean) at
System.Threading.TimerQueueTimer.CallCallback() at
System.Threading.TimerQueueTimer.Fire() at
System.Threading.TimerQueue.FireNextTimers() at
System.Threading.TimerQueue.AppDomainTimerCallback()
The only possible point of failure i can think of in FTPWebRequest is the timeoutVal, but i have changed this to infinite using:
request.Timeout = -1;
So any ideas as to why this is happening ?
Upvotes: 1
Views: 4878
Reputation: 515
Adding to what CodingFeles has said:
Should probably point out that this was a stupid mistake caused by nothing less than 10 hours of programming till 9am.... Ie. I was braindead at this point and introduced the error without realizing it:
The error was introduced because for some stupid reason, i accidentally commented out the network credentials for the FTP procedures and thats where everything stemmed from.
not saying that this will be your solution if you are also facing this issue.. But make sure you have the correct network credentials for the server and they are actually being passed through:
request.Credentials = new NetworkCredential("user", "pass");
Upvotes: 0
Reputation: 384
The only possible point of failure i can think of in FTPWebRequest is the timeoutVal
According to msdn System.Net.FtpWebRequest.GetRequestStream()
can throw these exceptions:
InvalidOperationException
WebException
ProtocolViolationException
.Exception info you provided explicitly states that you've encountered WebException
:
Exception Info: System.Net.WebException
According to msdn article I mentioned earlier that happens when
A connection to the FTP server could not be established.
Possible causes that you should check:
Considering that you debug it without any problems and you've encountered it only after deployment, I think that your FTP server can be unreacheable from the environment where you deployed your service to.
Upvotes: 1