vi / websocat

Command-line client for WebSockets, like netcat (or curl) for ws:// with advanced socat-like functions
MIT License
7.17k stars 278 forks source link

protocol_error #153

Open TonyStark opened 2 years ago

TonyStark commented 2 years ago

cmd=./websocat -t "wss://data.tradingview.com/socket.io/websocket?from=chart/" -H "Origin: https://www.tradingview.com" -v -v output=

[INFO  websocat::lints] Auto-inserting the line mode
[DEBUG websocat] Done third phase of interpreting options.
[DEBUG websocat] Done fourth phase of interpreting options.
[DEBUG websocat] Preparation done. Now actually starting.
[DEBUG websocat::sessionserve] Serving Line2Message(ThreadedStdio) to Message2Line(WsClient("wss://data.tradingview.com/socket.io/websocket?from=chart/")) with Options { websocket_text_mode: true, websocket_protocol: None, websocket_reply_protocol: None, udp_oneshot_mode: false, udp_broadcast: false, udp_multicast_loop: false, udp_ttl: None, udp_join_multicast_addr: [], udp_join_multicast_iface_v4: [], udp_join_multicast_iface_v6: [], udp_reuseaddr: false, unidirectional: false, unidirectional_reverse: false, max_messages: None, max_messages_rev: None, exit_on_eof: false, oneshot: false, unlink_unix_socket: false, unix_socket_accept_from_fd: false, exec_args: [], ws_c_uri: "ws://0.0.0.0/", linemode_strip_newlines: false, linemode_strict: false, origin: None, custom_headers: [("Origin", [104, 116, 116, 112, 115, 58, 47, 47, 119, 119, 119, 46, 116, 114, 97, 100, 105, 110, 103, 118, 105, 101, 119, 46, 99, 111, 109])], custom_reply_headers: [], websocket_version: None, websocket_dont_close: false, websocket_ignore_zeromsg: false, one_message: false, no_auto_linemode: false, buffer_size: 65536, broadcast_queue_len: 16, read_debt_handling: Warn, linemode_zero_terminated: false, restrict_uri: None, serve_static_files: [], exec_set_env: false, no_exit_on_zeromsg: false, reuser_send_zero_msg_on_disconnect: false, process_zero_sighup: false, process_exit_sighup: false, socks_destination: None, auto_socks5: None, socks5_bind_script: None, tls_domain: None, tls_insecure: false, headers_to_env: [], max_parallel_conns: None, ws_ping_interval: None, ws_ping_timeout: None, request_uri: None, request_method: None, request_headers: [], autoreconnect_delay_millis: 20, ws_text_prefix: None, ws_binary_prefix: None, ws_binary_base64: false, ws_text_base64: false, asyncstdio: false, foreachmsg_wait_reads: false, announce_listens: false, timestamp_monotonic: false, print_ping_rtts: false }
[INFO  websocat::stdio_threaded_peer] get_stdio_peer (threaded)
[DEBUG websocat::sessionserve] Underlying connection established
[INFO  websocat::ws_client_peer] get_ws_client_peer
[INFO  websocat::ws_client_peer] Connected to ws
[DEBUG websocat::ws_peer] incoming text
[DEBUG websocat::readdebt] Fullfulling the debt of 372 bytes
~m~363~m~{"session_id":"<0.1855.4172>_sin1-charts-21-webchart-14@sin1-compute-21_x","timestamp":1652206482,"timestampMs":1652206482323,"release":"registry.xtools.tv/tvbs_release/webchart:release_205-53","studies_metadata_hash":"916730cd03f4ed4a4c56ee57dc2f81f8cdadc2f3","protocol":"json","javastudies":"javastudies-3.61_2183","auth_scheme_vsn":2,"via":"23.106.253.81:443"}
[DEBUG websocat::ws_peer] incoming text
[DEBUG websocat::readdebt] Fullfulling the debt of 11 bytes
~m~4~m~~h~1

I pass this input ~m~54~m~{"m":"set_auth_token","p":["unauthorized_user_token"]} output=

[DEBUG websocat::ws_peer] incoming text
[DEBUG websocat::readdebt] Fullfulling the debt of 49 bytes
~m~41~m~{"m":"protocol_error","p":["wrong data"]}
[INFO  websocat::ws_peer] Received WebSocket close message
[DEBUG websocat::ws_peer] The close message is Some(CloseData { status_code: 1000, reason: "" })
[DEBUG websocat::my_copy] BrokenPipe: read_done
[DEBUG websocat::my_copy] done
[INFO  websocat::sessionserve] Reverse finished
[DEBUG websocat::sessionserve] Reverse shutdown finished

How to make it work? Thank you

vi commented 2 years ago

You may want to avoid using line mode, if that's what interferes with the communication. You may also want to use --base64 / --base64-text mode to specify arbitrary bytes for messages.

TonyStark commented 2 years ago

not working still get the same