GXNet.Open() causes randomly SocketExceptions

1 viestiä / 0 new
Uusin kirjoitus
Stier
Käyttäjän Stier kuva
GXNet.Open() causes randomly SocketExceptions

Hey Mikko

I actually dealing with a random problem with the GXNet.Open() Method. Inside Open the method ClientConnect is called. The connect attempt is limited to TIMEOUT_MILLISECONDS which is constant 5 seconds. After this 5 seconds (independently if the connect succeeds) there is a call to Socket.BeginReceive.
First, whats the purpose of this BeginReceive?
I get random SocketException when I try to connect meters via GSM/GPRS. Depends on how long the meter needs to connect and this varies a lot over the air. As I interpret the Exception, the problem occurs, if the 5 second timeout exceeds. After this 5 seconds the BeginReceive tries to execute, but the socket is not connected, which causes the following Exception:

System.Net.Sockets.SocketException (0x80004005): A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied
at System.Net.Sockets.Socket.BeginReceive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags, AsyncCallback callback, Object state)
at Gurux.Net.GXNet.ClientConnect(EndPoint ep) at Gurux.Net.GXNet.Open() at NP.Metering.Unit.Adapter.Dlms.GXDLMSCommunicator.Open()

I'm not sure if I interpret this problem correctly. Any suggestions from your side?
Thanks a lot for your help!

Best regards,
Andrea