Main Site Documentation

Http web request with ChipworkX


#1

My application on the ChipworkX does a heartbeat via an http web request (SSL) to a server every 30 seconds just to let the server know it is still up and running. Every 5 minutes it checks if there is any data to be sent up to the server and sends it via http web request as well (rolled up in a JSON string). Everything seems to work well but the units seem to experience a problem after several hours where the web request fails. It actually fails getting the response. see code line below.

response = (HttpWebResponse)request.GetResponse();

This is from the stack trace I log when the error occurs.

System.Net.HttpWebRequest::GetResponse

A simple reboot fixes it and it goes along fine doing this again for a while. I was able to work around it by simple rebooting the unit if it fails for more than 15 minutes in a row. So it basically reboots itself 2-3 times a day. I have double and triple checked that I close and dispose of everything during successful and unsuccessful connections.

Is there a problem with doing a web request like this so often? It is somewhat critical to the operation of the unit. Is there something that needs to be cleared every once in a while?


#2

try this linger option http://www.tinyclr.com/forum/topic?id=1901&page=1#msg19466


#3

Thanks Gus!

the HttpWebRequest doesn’t seem to have the linger option. I will take a look at replacing it with a socket connection.

Before I do that, do you think setting the KeepAlive property on the request object to false would be the same thing? I don’t think it would help but am not 100% sure. Has anyone used that before?


#4

Yes I remember now. You can’t set linger option for http.

Maybe using sockets will give you tighter control


#5

@ rncox: I have same problem long time ago. What error code do you get? Can you add some counter to code to see at which request number you get exception? I think that is problem with using all sockets… I know that on one HTTP Example here on GHI page has been something wrong and sockets has not be closed and when Im add closing streams(not only requests) to code…
Here is my thread:
http://www.tinyclr.com/forum/topic?id=4002&page=1
Check last few posts in thread if help you… But as Gus said using sockets is maybe best option :slight_smile: Also in my case after testing HttpWebRequest vs. Sockets Im get faster comunication with sockes…