Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot connect directly after a connection #12

Open
Jaapze opened this issue Jul 31, 2014 · 0 comments
Open

cannot connect directly after a connection #12

Jaapze opened this issue Jul 31, 2014 · 0 comments

Comments

@Jaapze
Copy link

Jaapze commented Jul 31, 2014

The library works great, my only problem is when i reset my arduino a few seconds after the connection is made, it cannot reconnect. I have to reset it a few times. I think its because pusher thinks there is already a connection. Is there a way to ask for a new connection, or reset any old connection? Or is it a bug in the library?

[UPDATE]
I now have the following code to try again after failing to make a connection (not very clean):

int i = 0;
int times = 4;
while(connectedToPusher == false && i < times){
delay(5*1000);
connectToPusher();
Serial.println("again");
i++;
}
if(connectedToPusher == false){
Serial.println("Could not connect, times tried: "+times);
}

boolean connectToPusher()
{
Serial.println("Try connect to pusher");
if(client.connect("8178511e2ae898735fc3")) {
Serial.println("connected");
connectedToPusher = true;
digitalWrite(7, HIGH);
client.bind("ledon", ledon);
client.bind("pusher:ping", checking);
client.bindAll(handleAllEvents);
client.subscribe("test_channel");
return true;
}
else {
Serial.println("failed");
return false;
while(1) {}
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant