I used C libwebsocket to test connect slack's websocket endpoint, however hit some unexpected error.
from logs, I see client get connected, but then server reply msg: CANCELLED: Failed to read message, then closed the socket.
我使用C libweb套接字测试连接Slak的WebSocket端点,但是遇到了一些意外错误。从日志中,我看到客户端已连接,但随后服务器回复消息:已取消:无法读取消息,然后关闭套接字。
the wss uri which I used is from:
curl -k -X POST "https://slack.com/api/apps.connections.open" -H "Content-type: application/x-www-form-urlencoded" -H "Authorization: Bearer xapp-1-xxxxxxxxxxxx"
我使用的wss uri来自:curl-k-X POST“https://slack.com/api/apps.connections.open”-H“内容类型:应用程序/x-www-form-urlencode”-H“授权:持有者xApp-1-xxxxxxxxxxx”
[2023/09/10 07:52:44:5042] I: lws_buflist_aware_read: wsi 0xdd2a8: lws_client_socket_service: ssl_capable_read 234
[2023/09/10 07:52:44:5043] D: lws_client_socket_service: buflist-aware-read 0 234
[2023/09/10 07:52:44:5045] I: lws_client_ws_upgrade: WSI_TOKEN_PROTOCOL is null
[2023/09/10 07:52:44:5046] D: Selected protocol
[2023/09/10 07:52:44:5046] D: lws_ensure_user_space: 0xdd2a8 protocol pss 0, user_space=(nil)
[6743]: test: wss cb, rs=2 len=0
[2023/09/10 07:52:44:5048] I: __lws_header_table_detach: wsi 0xdd2a8: ah 0x184c98 (tsi=0, count = 1)
[2023/09/10 07:52:44:5049] I: __lws_header_table_detach: nobody usable waiting
[2023/09/10 07:52:44:5050] I: _lws_destroy_ah: freed ah 0x184c98 : pool length 0
[2023/09/10 07:52:44:5050] I: __lws_header_table_detach: wsi 0xdd2a8: ah 0x184c98 (tsi=0, count = 0)
[2023/09/10 07:52:44:5051] D: lws_role_transition: 0xdd2a8: wsistate 0x10000119, ops ws
[2023/09/10 07:52:44:5052] I: _lws_validity_confirmed_role: wsi 0xdd2a8: setting validity timer 300s (hup 0)
[2023/09/10 07:52:44:5052] D: _realloc: size 262164: client frame buffer
[2023/09/10 07:52:44:5057] D: handshake OK for protocol
[6743]: test: wss cb, rs=3 len=256
[6743]: test: Client Connected:
[2023/09/10 07:52:44:5063] D: _lws_change_pollfd: wsi 0xdd2a8: fd 20 events 1 -> 5
[2023/09/10 07:52:44:5063] D: _lws_change_pollfd: wsi 0xdd2a8: fd 20 events 5 -> 5
[2023/09/10 07:52:44:5064] D: _lws_change_pollfd: wsi 0xdd2a8: fd 20 events 5 -> 1
[2023/09/10 07:52:44:5065] D: lws_handle_POLLOUT_event: 0xdd2a8: non mux: wsistate 0x10000119, ops ws
[2023/09/10 07:52:44:5065] D: _lws_change_pollfd: wsi 0xdd2a8: fd 20 events 1 -> 5
[2023/09/10 07:52:44:5066] D: 0xdd2a8: SSL_read says 36
[2023/09/10 07:52:44:5067] D: lws_read_h1: h1 path: wsi state 0x119
[2023/09/10 07:52:44:5068] D: lws_ws_handshake_client: hs client feels it has 36 in
[2023/09/10 07:52:44:5068] D: lws_ws_client_rx_sm: spilling as we have the whole frame
[2023/09/10 07:52:44:5069] D: lws_ws_client_rx_sm: starting disbursal of 34 deframed rx
[6743]: test: wss cb, rs=8 len=34
[6743]: test: Received message, msg=CANCELLED: Failed to read message.
[2023/09/10 07:52:44:5071] D: lws_ws_client_rx_sm: bulk ws rx: inp used 34, output 34
[2023/09/10 07:52:44:5073] D: _lws_change_pollfd: wsi 0xdd2a8: fd 20 events 5 -> 5
[2023/09/10 07:52:44:5074] D: _lws_change_pollfd: wsi 0xdd2a8: fd 20 events 5 -> 1
[2023/09/10 07:52:44:5074] D: lws_handle_POLLOUT_event: 0xdd2a8: non mux: wsistate 0x10000119, ops ws
[2023/09/10 07:52:44:5075] D: _lws_change_pollfd: wsi 0xdd2a8: fd 20 events 1 -> 5
[2023/09/10 07:52:44:5076] D: 0xdd2a8: SSL_read says 0
[2023/09/10 07:52:44:5076] D: lws_ssl_get_error: 0x186218 0 -> 6 (errno 0)
[2023/09/10 07:52:44:5077] D: 0xdd2a8: ssl err 6 errno 0
[2023/09/10 07:52:44:5078] I: rops_handle_POLLIN_ws: LWS_SSL_CAPABLE_ERROR
[2023/09/10 07:52:44:5078] D: 0xdd2a8: Close and handled
[2023/09/10 07:52:44:5079] I: __lws_close_free_wsi: 0xdd2a8: caller: close_and_handled
[2023/09/10 07:52:44:5080] D: __lws_close_free_wsi: real just_kill_connection: 0xdd2a8 (sockfd 20)
[2023/09/10 07:52:44:5081] D: lwsi_set_state(0xdd2a8, 0x10000020)
[6743]: test: wss cb, rs=75 len=0
[6743]: test: Client Closed
[6743]: test: wss cb, rs=30 len=0
[2023/09/10 07:52:44:5090] D: lws_vhost_unbind_wsi: vh default: count_bound_wsi 0
[2023/09/10 07:52:44:5090] D: __lws_free_wsi: 0xdd2a8, remaining wsi 1, tsi fds count 1
I also put above wss uri into online websocket test tool, like postman, it report same error msg.
我也把上面的wss uri放入了在线的WebSocket测试工具中,比如Postman,它报告了同样的错误消息。
更多回答
优秀答案推荐
我是一名优秀的程序员,十分优秀!