darrenjs / wampcc

WAMP C++ library
MIT License
73 stars 22 forks source link

Howto SSL client #9

Closed jamescraigziegler closed 6 years ago

jamescraigziegler commented 7 years ago

Do you have an example of how to use ssl_socket to connect to a wss://... URL?

darrenjs commented 7 years ago

Hi, I just added such an example, basic_callee_ssl.cc, it's very similar to basic_callee.cc. Hope that helps.

jamescraigziegler commented 7 years ago

Very useful, just one more question, the url is wss://something I can use ping to get the host ip, but how do I get the port number from that?

darrenjs commented 7 years ago

Well, if it following general convention, WS should be on port 80, and WSS 443. But, who ever provides the WSS server could have chosen their own ports.

jamescraigziegler commented 7 years ago

well, next issue: 20170816-19:27:15.204049 21351 WARN session #1 handhake error: server handshake must begin with magic octet 20170816-19:27:15.704267 21352 WARN session #1 timeout waiting for peer 20170816-19:27:15.704292 21352 INFO session #1 closing time-out during session logon

darrenjs commented 7 years ago

Hi ... that error happens when your client is using rawsocket protocol, but server uses websocket. Please check your example, around the line for wamp_session::create< ... >

jamescraigziegler commented 7 years ago

looking much better, where can I find documentation for the credentials structure and the session->hello call? (sorry to keep bugging you ....)

darrenjs commented 7 years ago

Hi .... the header file wamp_session.h will have the details of that structure. That structure is analogous to the Challenge Response Authentication interaction of the WAMP specification http://wamp-proto.org/static/rfc/draft-oberstet-hybi-crossbar-wamp.html#rfc.section.14.5.2.3. So to login, just provide the realm, authid, password function etc to an instance of the credentials object.

jamescraigziegler commented 7 years ago

so for this code snippet: promise ready_to_exit; shared_ptr session = wamp_session::create( the_kernel.get(), move(sock), [&ready_to_exit](wamp_session&, bool is_open) { if (!is_open) try { ready_to_exit.set_value(); } catch (...) { / ignore promise already set error / } }, {});

/* Logon to a WAMP realm, and wait for session to be deemed open. */
cout<<"Try to logon to session"<<endl;

client_credentials credentials;
credentials.realm="realm1";
credentials.authid="myname";
credentials.authmethods = {"wampcra"};
credentials.secret_fn = []() -> string { return "somestuff"; };

auto logon_fut = session->hello(credentials);

if (logon_fut.wait_for(chrono::seconds(45)) != future_status::ready)
  throw runtime_error("time-out during session logon");

I get this on the console: Try to logon to session time-out during session logon

How to diagnose this issue? Can I enable any other diagnostic output?

jamescraigziegler commented 7 years ago

hmmmm, set unique_ptr the_kernel(new kernel({}, logger::console())); then got Try to logon to session 20170818-13:35:29.489165 8576 WARN session #1 handhake error: http header is not a websocket upgrade 20170818-13:35:29.989327 8577 WARN session #1 timeout waiting for peer 20170818-13:35:29.989357 8577 INFO session #1 closing time-out during session logon

darrenjs commented 7 years ago

Hi,

Try to create a debug level logger, like auto logger = wampcc::logger::stream(wampcc::logger::lockable_cout, wampcc::logger::levels_upto(wampcc::logger::eDebug), true);

... and pass that to the wampcc:kernel constructor. I suspect the websocket server you are connecting too might be omitting a header when it sends a response to your program. But if you try this logger, it should dump the header it receives.

jamescraigziegler commented 7 years ago
like this?

auto logger = wampcc::logger::stream(wampcc::logger::lockable_cout, wampcc::logger::levels_upto(wampcc::logger::eDebug), true); / Create the wampcc kernel, which provides event and IO threads. / unique_ptr the_kernel(new kernel({}, logger::console()));

jamescraigziegler commented 7 years ago

this gave no change in output

jamescraigziegler commented 7 years ago

this worked better: auto mylogger = wampcc::logger::stream(wampcc::logger::lockable_cout, wampcc::logger::levels_upto(wampcc::logger::eDebug), true); / Create the wampcc kernel, which provides event and IO threads. / unique_ptr the_kernel(new kernel({}, mylogger));

got:

Try to logon to session 20170818-15:01:09.756089 7931 TRACE fd: 10, http_tx: GET / HTTP/1.1 Pragma: no-cache Cache-Control: no-cache Upgrade: websocket Connection: Upgrade Host: : Origin: main-maine Sec-WebSocket-Key: Sqk2utb9JLS2V5mmusQczA== Sec-WebSocket-Protocol: wamp.2.json,wamp.2.msgpack Sec-WebSocket-Version: 13

(websocket_protocol.cc:338) 20170818-15:01:09.756190 7932 TRACE fd: 10, tcp_tx: len 255, hex 474554202f20485454502f312e310d0a507261676d613a206e6f2d63616368650d0a43616368652d436f6e74726f6c3a206e6f2d63616368650d0a557067726164653a20776562736f636b65740d0a436f6e6e656374696f6e3a20557067726164650d0a486f73743a203a0d0a4f726967696e3a206d61696e2d6d61696e650d0a5365632d576562536f636b65742d4b65793a2053716b32757462394a4c533256356d6d757351637a413d3d0d0a5365632d576562536f636b65742d50726f746f636f6c3a2077616d702e322e6a736f6e2c77616d702e322e6d73677061636b0d0a5365632d576562536f636b65742d56657273696f6e3a2031330d0a0d0a (tcp_socket.cc:538) 20170818-15:01:09.791773 7932 TRACE fd: 10, tcp_rx: len 344, hex 485454502f312e31203430302042616420526571756573740d0a5365727665723a20636c6f7564666c6172652d6e67696e780d0a446174653a204672692c2031382041756720323031372031393a30313a303920474d540d0a436f6e74656e742d547970653a20746578742f68746d6c0d0a436f6e74656e742d4c656e6774683a203137370d0a436f6e6e656374696f6e3a20636c6f73650d0a43462d5241593a202d0d0a0d0a3c68746d6c3e0d0a3c686561643e3c7469746c653e3430302042616420526571756573743c2f7469746c653e3c2f686561643e0d0a3c626f6479206267636f6c6f723d227768697465223e0d0a3c63656e7465723e3c68313e3430302042616420526571756573743c2f68313e3c2f63656e7465723e0d0a3c68723e3c63656e7465723e636c6f7564666c6172652d6e67696e783c2f63656e7465723e0d0a3c2f626f64793e0d0a3c2f68746d6c3e0d0a (tcp_socket.cc:384) 20170818-15:01:09.791828 7932 TRACE fd: 10, http_rx: HTTP/1.1 400 Bad Request Server: cloudflare-nginx Date: Fri, 18 Aug 2017 19:01:09 GMT Content-Type: text/html Content-Length: 177 Connection: close CF-RAY: -

400 Bad Request

400 Bad Request


cloudflare-nginx

(websocket_protocol.cc:249) 20170818-15:01:09.791910 7932 WARN session #1 handhake error: http header is not a websocket upgrade (wamp_session.cc:632) 20170818-15:01:09.791982 7932 TRACE fd: 10, tcp_rx: len -4095 (tcp_socket.cc:384) 20170818-15:01:09.791989 7932 INFO session #1 closing (wamp_session.cc:2095) time-out during session logon

darrenjs commented 7 years ago

Hmmm. I wonder if its because the Host: header field you are sending is empty? Try with a non empty Host: field.

To specify host details, do something like this (see the admin.cc program for complete example).

/* websocket protocol options */
wampcc::websocket_protocol::options proto_opts;
proto_opts.connect_host="192.168.1.1";  // hostname or IP you try to connect to
proto_opts.connect_port="443";  // port number you try to connect to

/* create websocket, passing in the proto_opts */
wampcc::wamp_session::create<wampcc::websocket_protocol>(
        my_kernel.get(),
        std::move(sock),
        [](wampcc::wamp_session&, bool is_open) {
        /* your callback here */
        }, proto_opts);
darrenjs commented 7 years ago

If that doesn't work, another thing to try is to change the http header request that your program sends so that it uses lowercase for the Connection: Upgrade line.

To make that change, you will need to modify the wampcc source code and recompile everything.

The line to change is in file websocket_protocol.cc:318. Modify: Upgrade --> upgrade. Recompile all, make install, then rebuild your program.

jamescraigziegler commented 7 years ago

after both of these changes, still getting HTTP/1.1 400 Bad Request

darrenjs commented 7 years ago

Hi. Could you post the debug details again, like you did earlier? Perhaps there is now a different reply from the server. My worry though is that the websocket server you are trying to connect to has some idiosyncrasy in term of websocket support ... can be quite an effort to debug. Have you been able to connect to the server using a different websocket or wamp program (eg, python)?

jamescraigziegler commented 7 years ago

Here is the debug output. I have not tried any other websocket program. And thank you very much for your continuing support.

Try to logon to session 20170821-11:43:43.796812 5949 TRACE fd: 10, http_tx: GET / HTTP/1.1 Pragma: no-cache Cache-Control: no-cache Upgrade: websocket Connection: upgrade Host: 104.20.13.48:443 Origin: main-maine Sec-WebSocket-Key: eJ2zvZsQAQdNU1/QUdJ4+w== Sec-WebSocket-Protocol: wamp.2.json,wamp.2.msgpack Sec-WebSocket-Version: 13

(websocket_protocol.cc:338) 20170821-11:43:43.796887 5950 TRACE fd: 10, tcp_tx: len 270, hex 474554202f20485454502f312e310d0a507261676d613a206e6f2d63616368650d0a43616368652d436f6e74726f6c3a206e6f2d63616368650d0a557067726164653a20776562736f636b65740d0a436f6e6e656374696f6e3a20757067726164650d0a486f73743a203130342e32302e31332e34383a3434330d0a4f726967696e3a206d61696e2d6d61696e650d0a5365632d576562536f636b65742d4b65793a20654a327a765a73514151644e55312f5155644a342b773d3d0d0a5365632d576562536f636b65742d50726f746f636f6c3a2077616d702e322e6a736f6e2c77616d702e322e6d73677061636b0d0a5365632d576562536f636b65742d56657273696f6e3a2031330d0a0d0a (tcp_socket.cc:538) 20170821-11:43:43.826493 5950 TRACE fd: 10, tcp_rx: len 442, hex 485454502f312e31203430302042616420526571756573740d0a5365727665723a20636c6f7564666c6172652d6e67696e780d0a446174653a204d6f6e2c2032312041756720323031372031353a34333a343320474d540d0a436f6e74656e742d547970653a20746578742f68746d6c0d0a436f6e74656e742d4c656e6774683a203237350d0a436f6e6e656374696f6e3a20636c6f73650d0a43462d5241593a202d0d0a0d0a3c68746d6c3e0d0a3c686561643e3c7469746c653e3430302054686520706c61696e20485454502072657175657374207761732073656e7420746f20485454505320706f72743c2f7469746c653e3c2f686561643e0d0a3c626f6479206267636f6c6f723d227768697465223e0d0a3c63656e7465723e3c68313e3430302042616420526571756573743c2f68313e3c2f63656e7465723e0d0a3c63656e7465723e54686520706c61696e20485454502072657175657374207761732073656e7420746f20485454505320706f72743c2f63656e7465723e0d0a3c68723e3c63656e7465723e636c6f7564666c6172652d6e67696e783c2f63656e7465723e0d0a3c2f626f64793e0d0a3c2f68746d6c3e0d0a (tcp_socket.cc:384) 20170821-11:43:43.826547 5950 TRACE fd: 10, http_rx: HTTP/1.1 400 Bad Request Server: cloudflare-nginx Date: Mon, 21 Aug 2017 15:43:43 GMT Content-Type: text/html Content-Length: 275 Connection: close CF-RAY: -

400 The plain HTTP request was sent to HTTPS port

400 Bad Request

The plain HTTP request was sent to HTTPS port

cloudflare-nginx

(websocket_protocol.cc:249) 20170821-11:43:43.826657 5950 WARN session #1 handhake error: http header is not a websocket upgrade (wamp_session.cc:632) 20170821-11:43:44.326800 5951 WARN session #1 timeout waiting for peer (wamp_session.cc:1978) 20170821-11:43:44.326820 5951 INFO session #1 closing (wamp_session.cc:2095) time-out during session logon

darrenjs commented 7 years ago

Hi,

I can't think of what-else could be the problem here. Looks like the request your are sending is a valid websocket upgrade. I would next investigate the server. Looks like you are using cloudserve? Here are some other examples of same problem:

https://github.com/socketio/socket.io/issues/1942 https://github.com/jwilder/nginx-proxy/issues/128

darrenjs commented 7 years ago

Something else to try. In the http header request you send, perhaps the Pragma or Cache-Control lines are the problem. You can modify wampcc to remove those lines (delete websocket_protocol.cc lines 315 & 316). Then rebuild wampcc , make install etc, build your program.

jamescraigziegler commented 7 years ago

Same result... ;-(

Try to logon to session 20170822-11:33:30.276843 13589 TRACE fd: 10, http_tx: GET / HTTP/1.1 Upgrade: websocket Connection: upgrade Host: 104.20.13.48:443 Origin: main-maine Sec-WebSocket-Key: k4DCT94EIErk0ZMngavKXQ== Sec-WebSocket-Protocol: wamp.2.json,wamp.2.msgpack Sec-WebSocket-Version: 13

(websocket_protocol.cc:336) 20170822-11:33:30.276904 13590 TRACE fd: 10, tcp_tx: len 227, hex 474554202f20485454502f312e310d0a557067726164653a20776562736f636b65740d0a436f6e6e656374696f6e3a20757067726164650d0a486f73743a203130342e32302e31332e34383a3434330d0a4f726967696e3a206d61696e2d6d61696e650d0a5365632d576562536f636b65742d4b65793a206b344443543934454945726b305a4d6e6761764b58513d3d0d0a5365632d576562536f636b65742d50726f746f636f6c3a2077616d702e322e6a736f6e2c77616d702e322e6d73677061636b0d0a5365632d576562536f636b65742d56657273696f6e3a2031330d0a0d0a (tcp_socket.cc:538) 20170822-11:33:30.306882 13590 TRACE fd: 10, tcp_rx: len 442, hex 485454502f312e31203430302042616420526571756573740d0a5365727665723a20636c6f7564666c6172652d6e67696e780d0a446174653a205475652c2032322041756720323031372031353a33333a333020474d540d0a436f6e74656e742d547970653a20746578742f68746d6c0d0a436f6e74656e742d4c656e6774683a203237350d0a436f6e6e656374696f6e3a20636c6f73650d0a43462d5241593a202d0d0a0d0a3c68746d6c3e0d0a3c686561643e3c7469746c653e3430302054686520706c61696e20485454502072657175657374207761732073656e7420746f20485454505320706f72743c2f7469746c653e3c2f686561643e0d0a3c626f6479206267636f6c6f723d227768697465223e0d0a3c63656e7465723e3c68313e3430302042616420526571756573743c2f68313e3c2f63656e7465723e0d0a3c63656e7465723e54686520706c61696e20485454502072657175657374207761732073656e7420746f20485454505320706f72743c2f63656e7465723e0d0a3c68723e3c63656e7465723e636c6f7564666c6172652d6e67696e783c2f63656e7465723e0d0a3c2f626f64793e0d0a3c2f68746d6c3e0d0a (tcp_socket.cc:384) 20170822-11:33:30.306940 13590 TRACE fd: 10, http_rx: HTTP/1.1 400 Bad Request Server: cloudflare-nginx Date: Tue, 22 Aug 2017 15:33:30 GMT Content-Type: text/html Content-Length: 275 Connection: close CF-RAY: -

400 The plain HTTP request was sent to HTTPS port

400 Bad Request

The plain HTTP request was sent to HTTPS port

cloudflare-nginx

(websocket_protocol.cc:249) 20170822-11:33:30.307061 13590 WARN session #1 handhake error: http header is not a websocket upgrade (wamp_session.cc:632) 20170822-11:33:30.807241 13591 WARN session #1 timeout waiting for peer (wamp_session.cc:1978) 20170822-11:33:30.807267 13591 INFO session #1 closing (wamp_session.cc:2095) time-out during session logon

darrenjs commented 7 years ago

Hi

On that most recent attempt, the error message returned by the server is 400 The plain HTTP request was sent to HTTPS port -- this is different to what you've posted previously. Can you check your code to ensure you are indeed using an ssl_socket. It looks like at attempt is made using normal tcp socket.

Also, wampcc contains a program admin that can be used for this test:

admin   <HOST>  <PORT>   -d -d --proto ssl,web
jamescraigziegler commented 7 years ago

Ah yes, config disappeared when I added changes somewhere along the way... now I get:

Try to logon to session 20170822-14:47:51.913313 19471 TRACE fd: 10, http_tx: GET / HTTP/1.1 Upgrade: websocket Connection: upgrade Host: api.poloniex.com:443 Origin: main-maine Sec-WebSocket-Key: 4a+x6EEin8n9ZpKEAX+NLw== Sec-WebSocket-Protocol: wamp.2.json,wamp.2.msgpack Sec-WebSocket-Version: 13

(websocket_protocol.cc:336) 20170822-14:47:51.988382 19472 TRACE fd: 10, ssl handshake success (ssl_socket.cc:232) 20170822-14:48:02.413504 19473 WARN session #1 timeout waiting for peer (wamp_session.cc:1978) 20170822-14:48:02.413533 19473 INFO session #1 closing (wamp_session.cc:2095) time-out during session logon j

darrenjs commented 7 years ago

Perhaps try to revert the Connection: upgrade to Connection: Upgrade. Looks like the end-point server is not replying to the websocket upgrade request. I.e., I think you are now getting through the initial nginx server; maybe that is a load balancer to something behind it?

jamescraigziegler commented 7 years ago

Try to logon to session 20170822-14:54:35.454918 20099 TRACE fd: 10, http_tx: GET / HTTP/1.1 Pragma: no-cache Cache-Control: no-cache Upgrade: websocket Connection: Upgrade Host: api.poloniex.com:443 Origin: main-maine Sec-WebSocket-Key: DjRdQHm+726XMp0tlilVWQ== Sec-WebSocket-Protocol: wamp.2.json,wamp.2.msgpack Sec-WebSocket-Version: 13

(websocket_protocol.cc:338) 20170822-14:54:35.521849 20100 TRACE fd: 10, ssl handshake success (ssl_socket.cc:232) 20170822-14:54:45.955105 20101 WARN session #1 timeout waiting for peer (wamp_session.cc:1978) 20170822-14:54:45.955135 20101 INFO session #1 closing (wamp_session.cc:2095) time-out during session logon

jamescraigziegler commented 7 years ago

I've also opened a trouble ticket with poloniex, no response so far

jamescraigziegler commented 7 years ago

Ah ha! Started again several times, and one time got: Try to logon to session 20170822-15:13:00.971799 20348 TRACE fd: 10, http_tx: GET / HTTP/1.1 Pragma: no-cache Cache-Control: no-cache Upgrade: websocket Connection: Upgrade Host: api.poloniex.com:443 Origin: main-maine Sec-WebSocket-Key: NsjineBN4WxWkmKTT+zlwA== Sec-WebSocket-Protocol: wamp.2.json,wamp.2.msgpack Sec-WebSocket-Version: 13

(websocket_protocol.cc:338) 20170822-15:13:01.052367 20349 TRACE fd: 10, ssl handshake success (ssl_socket.cc:232) 20170822-15:13:06.650829 20349 TRACE fd: 10, http_rx: HTTP/1.1 101 Switching Protocols Date: Tue, 22 Aug 2017 19:13:06 GMT Connection: upgrade Set-Cookie: __cfduid=dbceaacfdee12af34d3b4594f4e2b74651503429181; expires=Wed, 22-Aug-18 19:13:01 GMT; path=/; domain=.poloniex.com; HttpOnly X-Powered-By: AutobahnPython/0.13.0 Upgrade: WebSocket Sec-WebSocket-Protocol: wamp.2.json Sec-WebSocket-Accept: 9ax2y+SzadN/TZFxgOacHdYqBZM= Server: cloudflare-nginx CF-RAY: 3928259daf765a5c-BOS

(websocket_protocol.cc:249) 20170822-15:13:06.650883 20349 INFO session #1 state: from init to sent_hello (wamp_session.cc:443) 20170822-15:13:06.650931 20349 TRACE fd: 10, json_tx: [1, "realm1", {"agent": "wampcc 1.4", "authid": "XXX@YYYYYY.ZZZZ", "authmethods": ["wampcra"], "roles": {"callee": {}, "caller": {}, "publisher": {}, "subscriber": {}}}] (websocket_protocol.cc:111) 20170822-15:13:06.650961 20349 TRACE fd: 10, frame_tx: fin 1, opcode 1, payload_len 164 (websocket_protocol.cc:135) 20170822-15:13:07.899775 20349 TRACE fd: 10, frame_rx: fin 1, opcode 1, payload_len 115 (websocket_protocol.cc:440) 20170822-15:13:07.899814 20349 TRACE fd: 10, json_rx: [3, {"message": "cannot authenticate using any of the offered authmethods [u'wampcra']"}, "wamp.error.no_auth_method"] (protocol.cc:174) 20170822-15:13:07.899859 20350 WARN session #1 received ABORT from peer, closing session (wamp_session.cc:469) 20170822-15:13:07.899876 20350 TRACE fd: 10, frame_tx: fin 1, opcode 8, payload_len 2 (websocket_protocol.cc:346) 20170822-15:13:08.683266 20349 TRACE fd: 10, frame_rx: fin 1, opcode 8, payload_len 2 (websocket_protocol.cc:440) 20170822-15:13:08.683865 20349 INFO session #1 closing (wamp_session.cc:2095) time-out during session logon

jamescraigziegler commented 7 years ago

Looks like authentication issue now, waiting for response from poloniex

jamescraigziegler commented 7 years ago

is there a simple way to increase the timeout reported at wamp_session.cc:1978? poloniex may be slower than that....

darrenjs commented 7 years ago

Nice progress! Next trouble might be that the only authentication method currently supported by wampcc is wampcra, so I do hope they will offer that. Otherwise try to find out what they do support. Something you can try is to disable sending wampcra -- perhaps they will allow you to login without authentication? To do this, in your code you should be assigning something like: authmethods = {"wampcra"} ; just comment that out so that the authmethods is left blank.

darrenjs commented 7 years ago

It is not your client connection which is timing out. Your program is being kicked off the server. They are sending your a session ABORT message. And reason is you are offering the wampcra authentication method, but the server is saying they don't support it. So I wonder what they do support?

jamescraigziegler commented 7 years ago

I only get the ABORT about once out of 10 times, otherwise I get:

Try to logon to session 20170822-15:25:45.964961 20452 TRACE fd: 10, http_tx: GET / HTTP/1.1 Pragma: no-cache Cache-Control: no-cache Upgrade: websocket Connection: Upgrade Host: api.poloniex.com:443 Origin: main-maine Sec-WebSocket-Key: OBINfTLv3oDjF+UXXPUCdg== Sec-WebSocket-Protocol: wamp.2.json,wamp.2.msgpack Sec-WebSocket-Version: 13

(websocket_protocol.cc:338) 20170822-15:25:46.032018 20453 TRACE fd: 10, ssl handshake success (ssl_socket.cc:232) 20170822-15:25:56.465147 20454 WARN session #1 timeout waiting for peer (wamp_session.cc:1978) 20170822-15:25:56.465178 20454 INFO session #1 closing (wamp_session.cc:2095) time-out during session logon

Which is why I wonder if I need to wait longer for them.....

darrenjs commented 7 years ago

Ah I see. This is likely in your main program. There will be some code like:

if (logon_fut.wait_for(std::chrono::seconds(5)) != std::future_status::ready)
  throw std::runtime_error("time-out during session logon");

... try changing the 5 to 60 or something.

jamescraigziegler commented 7 years ago

that controls when the time-out during session logon message appears, I have that set to 45 seconds, but the 20170822-15:25:56.465147 20454 WARN session #1 timeout waiting for peer (wamp_session.cc:1978) message comes after about 8 seconds

darrenjs commented 7 years ago

Well, that line wamp_session.cc:1978 is only called when the session is already on its way to being closed. So looks like there is some logging missing in wampcc which would tell us why the socket is being closed (is it from your side, or from the server?). It looks like 10 seconds, from your log file. In the source code, I found this:

 std::chrono::milliseconds max_pending_open { 10000 };

When you create your wamp_session object, via create, the create method allows you to specify this timeout. So add something like , {std::chrono::milliseconds(1000*120)} to the create method, as the final argument.

jamescraigziegler commented 7 years ago

When I try without authmethods, I get: 20170822-15:51:42.770609 21635 TRACE fd: 10, ssl handshake success (ssl_socket.cc:232) 20170822-15:51:49.783183 21635 TRACE fd: 10, http_rx: HTTP/1.1 101 Switching Protocols Date: Tue, 22 Aug 2017 19:51:49 GMT Connection: upgrade Set-Cookie: __cfduid=d0caa4f9cc78e23bded26a2dc1537fb911503431502; expires=Wed, 22-Aug-18 19:51:42 GMT; path=/; domain=.poloniex.com; HttpOnly X-Powered-By: AutobahnPython/0.13.0 Upgrade: WebSocket Sec-WebSocket-Protocol: wamp.2.json Sec-WebSocket-Accept: V5xRpXBlhSI5s3zbZQXsFSERnAQ= Server: cloudflare-nginx CF-RAY: 39285e4c6f835a68-BOS

(websocket_protocol.cc:249) 20170822-15:51:49.783232 21635 INFO session #1 state: from init to sent_hello (wamp_session.cc:443) 20170822-15:51:49.783286 21635 TRACE fd: 10, json_tx: [1, "realm1", {"agent": "wampcc 1.4", "authid": "XXX@YYYYYY.ZZZZ", "authmethods": [], "roles": {"callee": {}, "caller": {}, "publisher": {}, "subscriber": {}}}] (websocket_protocol.cc:111) 20170822-15:51:49.783329 21635 TRACE fd: 10, frame_tx: fin 1, opcode 1, payload_len 155 (websocket_protocol.cc:135) 20170822-15:51:52.587395 21636 TRACE fd: 10, json_tx: [3, {}, "wamp.error.logon_timeout"] (websocket_protocol.cc:111) 20170822-15:51:52.587432 21636 TRACE fd: 10, frame_tx: fin 1, opcode 1, payload_len 35 (websocket_protocol.cc:135) 20170822-15:51:53.087449 21636 WARN session #1 timeout waiting for peer (wamp_session.cc:1978) 20170822-15:51:53.087468 21636 INFO session #1 closing (wamp_session.cc:2095) time-out during session logon

jamescraigziegler commented 7 years ago

With respect to: When you create your wamp_session object, via create, the create method allows you to specify this timeout. So add something like , {std::chrono::milliseconds(1000*120)} to the create method, as the final argument. I am already passing websocket_protocol::options proto_opts, would this be another option? named?

darrenjs commented 7 years ago

Ah ... I think I made mistake there. It looks like that option cannot be provided via the create call, sorry. Will have to fix that. In meantime, you can alter wampcc source code, to change line: wamp_session.h:359 ... make it very high number. Then rebuild all, make -j install etc.

jamescraigziegler commented 7 years ago

After increase of that timeout, all seems to be working.....

jamescraigziegler commented 7 years ago

Great progress...on the subscribe side...after I bask in success some, I'll try some RPC.... Thank you so much.....

darrenjs commented 7 years ago

:-) nice .... I'll go over this thread and make the changes to wampcc in the master branch. So in a later version you should not have to hack about with wampcc.

jamescraigziegler commented 7 years ago

In the end, I think the only change in the master was the timeout..... Everything else was my learning curve...

darrenjs commented 7 years ago

I think it might also have been the Host field, missing from the HTTP header. Originally you were being given Bad Request reply. It would make sense to put that it, ie, to automatically fill in those fields. As for the delay, i'll change to 60 seconds.

petten commented 7 years ago

Darren, I'm looking into turning on/using SSL in my wampcc client, too. But the router has to use the same.

I've been using bonefish as the router (as you know) over its --websocket endpoint (as opposed to its --rawsocket), But it appears to me that bonefish built by default uses the straight ws scheme without giving the user a choice of switching to wss.

I just saw you had a fork of bonefish.

Do you have insights about turning on wss in bonefish (build + any necessary modification)?

darrenjs commented 7 years ago

Hi,

I don't think the bonefish router supports SSL out-of-the-box. There doesn't seem to be any option to enable SSL at the command line etc.

So you might have to modify the source code of bonefish to add SSL support. This might not be so difficult. Bonefish uses websocketpp, which does have support for TLS.

I would start by looking at the pure websocketpp example called "echo_server_tls.cpp" (it is included underneath the websocketpp directory) which shows how to configure the websocketpp class to support SSL. Then copy those ideas into the bonefish code. The wampcc client should work with SSL immediately.

An alternatively, look at something like https://github.com/bumptech/stud

petten commented 7 years ago

Thanks Darren for your insights.

As an alternative for me, I tried using an nginx proxy to the router (bonefish). It worked.

I can use the admin program in wampcc to send messages using wss to the nginx; previously the same messages were sent using ws to the bonefish directly.

One of our wampcc clients will be using wss (just like the admin), whereas the other sitting behind the nginx (on the same side as the bonefish) will still talk straight ws with the bonefish.

So for now I don't have an urgent need to modify bonefish to support wss.

darrenjs commented 7 years ago

nice solution, interesting to know.

darrenjs commented 6 years ago

Issue fixed in wampcc 1.5, added wamp_session timeout parameter.
commit 4c70095932ede90b77cf0ca84b6a14dc41d025f4

darrenjs commented 6 years ago

@jamescraigziegler -- did you manage to get your client to poloniex to work? Seems there is another issue regarding it (#5)