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 emit with TLS mode #19

Closed
cewh opened this issue Jun 1, 2015 · 4 comments
Closed

How to emit with TLS mode #19

cewh opened this issue Jun 1, 2015 · 4 comments

Comments

@cewh
Copy link

cewh commented Jun 1, 2015

Thanks for including TLS.
I was having trouble emitting a simple message using the following code, I am probably doing something wrong;

sio::client h;
h.connect("https://127.0.0.1:1337");
h.socket()->on("pong", (sio::socket::event_listener)&OnMessage);
std::string test = "abc";
h.socket()->emit("ping", test);

The server side does not obtain the emitted message "ping".
The console reports:

[2015-06-01 14:55:26] [devel] endpoint constructor
[2015-06-01 14:55:26] [devel] client constructor
Close by reason:End by user
Error: No active session
[2015-06-01 14:55:26] [connect] Successful connection
[2015-06-01 14:55:26] [connect] WebSocket Connection 127.0.0.1:1337 v-2 "WebSock
et++/0.5.1" /socket.io/?EIO=4&transport=websocket&t=1433134526 101
Connected.
On handshake,sid:qefZuQzvE3KaklymAAAB,ping interval:25000,ping timeout60000
Received Message type (Connect)

The part about "close by reason" is a cause of concern, I tried looking through the code but I'm not sure what would cause this.

@mdeforge
Copy link

mdeforge commented Jun 1, 2015

I don't need this line in my project: h.socket()->on("pong", (sio::socket::event_listener)&OnMessage);

Have you seen the console example? I was able to modify that for my needs. Currently running C++ and Javascript clients with a Node.js server in between.

@melode11
Copy link
Contributor

melode11 commented Jun 1, 2015

  1. Your client object is stack allocated, so it'll destruct when run out of scope, that's why "end by user" happened.
    You need to wait as long as the connection lives,see console demo.
  2. The TLS feature is not controlled by the "https" in url, it is controlled by "SIO_TLS" macro at compile time.

@cewh
Copy link
Author

cewh commented Jun 2, 2015

I found the error in my code from your console example. I'll close the issue and thanks for the response!

@cewh cewh closed this as completed Jun 2, 2015
@cewh
Copy link
Author

cewh commented Jun 2, 2015

I am working with the modified console example. The emit works and is received on the server side, I am also noticing a message every time I emit, I get the console message;

ping exit,con is expired?0,ec:The I/O operation has been aborted because of either 
a thread exit or an application request

The message comes from within client_impl::ping would this be related to ping interval or ping timeout setting?

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

3 participants