• We are using .NETMF 4.1
• GHIElectronics.NETMF 4.17
• DPWS_V_4_1_7706_0
• WsHttp configured web services
When the network is not available and a web service call is attempted, The call blocks for an inordinate amount of time (~90 seconds) thus blocking all processing on the device and rendering it frozen. This is not acceptable behavior. It should honor a timeout or throw an exception in a much shorter period of time.
As I know this is problem in NETMF4.1 and will be fixed in NETMF4.2 You can temporary override it that you in other thread try open socket to IP 8.8.8.8. or some other public IP and in main thread check if you for example in 5 seconds succesfully connect make your DPWS request and if not then is something wrong with network and you terminate thread…
Other functions to check host like:
I understand that… and in fact that is what I have done to probe the network prior to making the call. However, my point is that it shouldn’t be that way. There needs to be a way to set a timeout on the call of interest. What happens if the network probe call succeeds because the network was up but then in a split second between the probe call and the actual service call it goes down. This race condition is possible albeit not as likely… It begs the question then, should we spend all this effort creating workarounds or should we invest that time in making the networking stack more robust. If you run a similar test on .NET full you will see how the network behavior should be under these conditions.
As Im said this is not problem in GHI libraryes because EMX and ChipworkX use native .NETMF sockets. As I know this blockings are fixed In .NETMF 4.2 as users report… So you can use override as I use now or wait few months for .NETMF4.2 update.
Yes netmf doesn’t detect a cable disconnect and close sockets immediately. I think users normally handle this by terminating the thread handling the socket.
Only under some conditions. Unless you’re using TCP KeepAlive, there’s no way to know whether there’s a complete, functioning network between you and your destination except to try to use it (and that’s essentially what KeepAlive does, it sends packets back and forth every so often).
Sending a packet involves some wait to see if it was received. The reason it works better for you on the desktop is because the actual packet send fails when the network is unplugged, not because it has some magic way to know that there’s no connection.