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!
I did some more investigation in the GXNet.Open() problem. I took the source of GXNet, replaced the constant TIMEOUT_MILLISECONDS with an exposed porperty within the GXNet.cs and increased the timeout in my application to 30 seconds. Since there the SocketException does not occur anymore within the Open method. Seems to be a solution to my problem, but I 'm still wondering about the BeginReceive after the connect?
Thanks a lot for your effort, that will help a lot!
I'm still curious about the BeginReceive after connect? Whats the purpose of this receive? Does the meter send some data after connect?
Funny concept to send data right after the connect, but I already experienced a lot of funny (or annoying) features with "smart" meters! :D
But anyway, thanks for your info!
Some protocols are using so-called readout-mode. It means that meters are quite simple and they just report current values after the connection is made. You can't ask anything from the meter.
Further investigation in the GXNet.Open() problem
Hey Mikko,
I did some more investigation in the GXNet.Open() problem. I took the source of GXNet, replaced the constant TIMEOUT_MILLISECONDS with an exposed porperty within the GXNet.cs and increased the timeout in my application to 30 seconds. Since there the SocketException does not occur anymore within the Open method. Seems to be a solution to my problem, but I 'm still wondering about the BeginReceive after the connect?
Best regards,
Andrea
Further investigation in the GXNet.Open() problem
Hi Andrea,
I see your problem. We'll add this wait time to media component so you can increase it if needed.
We release new version tomorrow.
BR,
Mikko
Further investigation in the GXNet.Open() problem
Hi Mikko,
Thanks a lot for your effort, that will help a lot!
I'm still curious about the BeginReceive after connect? Whats the purpose of this receive? Does the meter send some data after connect?
Best regards,
Andrea
Further investigation in the GXNet.Open() problem
Hi,
BeginReceive start listens received messages. Some meter might send data right away.
BR,
Mikko
Further investigation in the GXNet.Open() problem
Hi Mikko
Funny concept to send data right after the connect, but I already experienced a lot of funny (or annoying) features with "smart" meters! :D
But anyway, thanks for your info!
Best regards,
Andrea
Further investigation in the GXNet.Open() problem
Hi,
Some protocols are using so-called readout-mode. It means that meters are quite simple and they just report current values after the connection is made. You can't ask anything from the meter.
BR,
Mikko