billroy / socket.io-arduino-client

A socket.io client for the Arduino Ethernet shield
MIT License
195 stars 66 forks source link

Best way to keep connection alive? #1

Open chriswhong opened 11 years ago

chriswhong commented 11 years ago

Thanks for making this awesome library available. I've successfully used it in a socket.io-powered Window Air Conditioner Remote, but am curious if anyone knows a good way to deal with interrupted connections.

Basically, what's the best way to have an arduino check it's connection periodically and reconnect if it is not connected?

billroy commented 11 years ago

Thanks for your note, and your kind words. I've pushed a change that will automatically reconnect in the monitor() function. It's just these lines added near the top of monitor():

if (!client.connected()) {
    if (!client.connect(hostname, port)) return;
}

Git pull or add those lines to monitor() and you should be in business. I haven't tested it here so you're the guinea pig -- please do let me know how it works.

Best regards,

-br

chriswhong commented 11 years ago

Thanks! I added the code today so we'll see how things go. I am using "forever" to keep my node.js server running continuously but that seems to have issues as well. I'll keep you posted.

mattes commented 10 years ago

any updates, @chriswhong ? ;-)

chriswhong commented 10 years ago

Sorry, haven't touched this in over a year, and these days there are devices that take the hassle out of getting an arduino on the web (like sparkcore, which is what I've been using lately for connected devices)

On Wed, Mar 12, 2014 at 9:41 PM, Matthias Kadenbach < notifications@github.com> wrote:

any updates, @chriswhong https://github.com/chriswhong ? ;-)

Reply to this email directly or view it on GitHubhttps://github.com/billroy/socket.io-arduino-client/issues/1#issuecomment-37491375 .

dasaievcastro commented 10 years ago

Hi, When I make about 10000 connections my arduino hangs. Any help?

chriswhong commented 10 years ago

None, sorry. Haven't messed with arduinos for a bit. Good luck. On Mar 21, 2014 5:41 PM, "dasaievcastro" notifications@github.com wrote:

Hi, When I make about 10000 connections my arduino hangs. Any help?

Reply to this email directly or view it on GitHubhttps://github.com/billroy/socket.io-arduino-client/issues/1#issuecomment-38327220 .

mattes commented 10 years ago

Just curious: Connections per second/ minutes/ ..? @dasaievcastro

dasaievcastro commented 10 years ago

Hi @mattes, estou enviando 5/minutes. I'm doing stress test. If we decrease the connection number up to 18000. But the hangs continue.