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

How to enable Debug and Ratchet? #38

Closed
diegocpires opened this issue Jan 6, 2016 · 6 comments
Closed

How to enable Debug and Ratchet? #38

diegocpires opened this issue Jan 6, 2016 · 6 comments

Comments

@diegocpires
Copy link

Sorry for the noob question.

I see many times in issues the line for enable debug. In line 30 in WebSockets.h
But, i dont understand what i need put in line 30 for debug works.
I tried Serial, Serial1, Serial2, Serial3... But no ones works. In all cases i got an error in compilation.

I need to debug because Arduino is not connecting the WebSocket server made in Ratchet (PHP).
I see the connection in Ratchet console, but Arduino disconnects immediately following.

Anyone Can help me?

@diegocpires diegocpires changed the title How to enable Debug and Ratched? How to enable Debug and Ratchet? Jan 6, 2016
@diegocpires
Copy link
Author

Replacing DEBUG_WEBSOCKETS with Serial.println i can see the moment of error.

When call function acceptKey. The validation it is not working.

From Firefox I connect in WebSocket Server. Any ideas for resolve this problem?

@diegocpires
Copy link
Author

For Example

For send Web-Socket-Key 17Gf8QiZr8lDr/aU9ePVFQ== the correct Sec-WebSocket-Accept is rssLO9/Rz1QGFYktqTxzJ5viYUc=, but the function acceptKey returns Kfh9QIsMVZcl6xEPYxPHzW8SZ8w=

@Links2004
Copy link
Owner

do you use the ESP8266 or a ATmega?
for ESP8266 will work:

/// Serial
#define DEBUG_WEBSOCKETS(...) Serial.printf( __VA_ARGS__ )
/// Serial1
#define DEBUG_WEBSOCKETS(...) Serial1.printf( __VA_ARGS__ )

the avr not support printf for print class.
but you can use printf.

#include <stdio.h>
static FILE uartout = {0} ;
static int uart_putchar (char c, FILE *stream)
{
    Serial.write(c) ;
    return 0 ;
}

void setup(void)
{
   Serial.begin(115200);
   fdev_setup_stream (&uartout, uart_putchar, NULL, _FDEV_SETUP_WRITE);
   stdout = &uartout ;
}
#define DEBUG_WEBSOCKETS(...) printf( __VA_ARGS__ )

with printf you will see the acceptKey that is send to the server and the AcceptKey

@diegocpires
Copy link
Author

Hi @Links2004, thanks for the answer.
Im using ATmega with AVR.

But, replacing and testing, I got the problem above.
#38 (comment)

@Links2004
Copy link
Owner

try to change
https://github.com/Links2004/arduinoWebSockets/blob/master/src/WebSockets.cpp#L400
too:

    clientKey += "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";

look like the + and = are mixed

@diegocpires
Copy link
Author

Wow @Links2004 .

This Works like a charm! Very Very Thanks.

Can i close this issue?

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

2 participants