Socket Exception - WeOnlyDo Discussion board

Socket Exception (wodFtpDLX / wodFtpDLX.NET)

by Daniel Dority, Friday, January 22, 2016, 18:24 (3228 days ago)

I have five threads processing 200 download requests each for a total of 1000 files through their own instance of an FtpDlx object.

Each client ALWAYS throws this exception when it has processed exactly 130 files:

System.IO.IOException: Unable to read data from the transport connection: An attempt was made to access a socket in a way forbidden by its access permissions. ---> System.Net.Sockets.SocketException: An attempt was made to access a socket in a way forbidden by its access permissions
   at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   --- End of inner exception stack trace ---
   at WeOnlyDo.Net.Sockets.SSLSocket.EndReceive(IAsyncResult ar)
   at WeOnlyDo.Net.Sockets.ProxySocket.EndReceive(IAsyncResult asyncResult)
   at WeOnlyDo.Protocols.FTPplain.ReceiveNotification(IAsyncResult ar)


Initiating call: m_FtpDlx.GetFile(Path.GetTempFileName(), "PATH_ON_SERVER");

I can replicate this behavior every single time with a single client or dozens.

I do receive a StateChange event with the above mentioned exception and a state change to Disconnected.

I do recover gracefully from this; however, I am curious as to the root cause.

(Thoughts?)

FtpDLX client settings (options not mentioned use vendor defaults)


  Port:  21
  Protocol:  2   (FTPS)
  Timeout:  0
  Passive:  true
  Blocking:  false
  TransferMode:  0    (Binary)

Socket Exception

by Jasmine, Friday, January 22, 2016, 18:27 (3228 days ago) @ Daniel Dority

Hi Daniel.

You are using threads, and you don't use blocking? This could be possible problem, since in thread wodFtpDLX cannot use in async mode.

If you switch to Blocking = true, does it work ok?

Regards,
Jasmine.

Socket Exception

by Daniel Dority, Friday, January 22, 2016, 21:09 (3228 days ago) @ Jasmine

I guess my description was a bit misleading. I have a built an FTP wrapper for the FtpDLX client that implements the recommended state checking approach to match up commands to completion events.

Each thread has its own FTP wrapper class which includes its own FtpDLX object.

Does this help clarify the scenario?

Socket Exception

by Jasmine, Friday, January 22, 2016, 22:19 (3228 days ago) @ Daniel Dority

Hi Daniel.

We need a way to isolate the issue. Can you please try same thing but only with one thread, just for the test?

After that, try also only one instance, but from the main thread (without additional threads).

Do you get same results?

Jasmine.

Socket Exception

by Daniel Dority, Friday, January 22, 2016, 22:42 (3228 days ago) @ Jasmine

Yes, I had mentioned in the first post that this happens on a single thread and upwards to 10. I haven't thrown more than 10 threads at it with 5 being the ideal for our long running processes.

That means that single thread will be processing 1000 files in a single runtime session. I can't remember if it happens repeatedly in a single session (like after every 130 records).

I can re-run that test after the current run is finished.

Socket Exception

by Jasmine, Saturday, January 23, 2016, 11:33 (3227 days ago) @ Daniel Dority

Hi Daniel.

I'm not 100% sure I understand 'single thread' what happens.

Anyway, we must isolate if this happens only when it runs in separate thread, or also when it happens in main thread.

Is that something we could try to duplicate from our side, in debugging mode?

Jasmine.