awslabs / amazon-kinesis-video-streams-webrtc-sdk-c

Amazon Kinesis Video Streams Webrtc SDK is for developers to install and customize realtime communication between devices and enable secure streaming of video, audio to Kinesis Video Streams.
https://awslabs.github.io/amazon-kinesis-video-streams-webrtc-sdk-c/group__PublicMemberFunctions.html
Apache License 2.0
1.03k stars 312 forks source link

[QUESTION] turns server always send RST to libnice socket during TLS handshake #1585

Closed yh8004kim closed 1 year ago

yh8004kim commented 1 year ago

I have try to connect your KVS turn server at target (RPI4) with Tizen (Samsung) API. turn server is always succeed but we can't connect turns server.

As you know, gstreamer's webrtc depends on libnice as below.

gst_webrtc_ice_constructed (GObject * object)
{
...
  ice->priv->nice_agent = nice_agent_new_full (ice->priv->main_context,
      NICE_COMPATIBILITY_RFC5245, options);

When I check libnice once more, libnice does not actually support RFC 6062 (TURN-TCP) and TCP simultaneous-open (S-O) now. Libnice TODO

Standard (RFC 6062) TURN-TCP ... TCP simultaneous-open (S-O)

About RFC 6062 (TURN-TCP) and TCP simultaneous-open, I can find TLS handshake can be failed as below's appendix part. https://datatracker.ietf.org/doc/html/draft-ietf-mmusic-ice-tcp-15#ref-IMC05 (appendix-A). Limitations of ICE TCP and appendix-B). Implementation Considerations for BSD Sockets)

So I wonder if KVS turns server would not permit to connect when libnice can't meet RFC 6062 or TCP simultaneous-open now. Can you check my question about our issue of turns server tls handshake failure?

If you have any questions about my question, please let me know in detail.

Logging Add relevent SDK logging. IMPORTANT NOTE: Please make sure to NOT share AWS access credentials under any circumstance! Please make sure they are not in the logs. When KVS turns sever failed, I can dump the packet as below through wireshark.

[wireshark packet dump] 192.168.0.3 3.37.44.221 TCP 74 51840 -> 443 [SYN] Seq=0 Win=65535 Len=0 MSS=1460 SACK_PERM=1 TSval=... 3.37.44.221 192.168.0.3 TCP 74 443 -> 51840 [SYN, ACK] Seq=0 Ack=1 Win=26847 Len=0 MSS=1460 SACK_PERM=1 TSval=... 192.168.0.3 3.37.44.221 TCP 66 51840 -> 443 [ACK] Seq=1 Ack=1 Win=65536 Len=0 TSval=... 192.168.0.3 3.37.44.221 SSL 106 Continuation Data 3.37.44.221 192.168.0.3 TCP 66 443 -> 51840 [ACK] Seq=1 Ack=41 Win=26880 Len=0 TSval=... 3.37.44.221 192.168.0.3 TCP 66 443 -> 51840 [RST, ACK] Seq=1 Ack=41 Win=26880 Len=0 TSval=...

[gstreamer and libnice log] 11-01 10:35:28.427 D/LIBNICE_AGENT(P 7300, T 7508): agent.c: agent_socket_send(7334) > sock 0x15d7548 FD 74 nice_socket_send_reliable result 40 11-01 10:35:28.427 D/LIBNICE_AGENT(P 7300, T 7508): agent.c: agent_socket_send(7337) > sock 0x15d7548 FD 74 addr 0x164a008 len 40 buf 0x164c5ec result 0 11-01 10:35:28.427 D/TIZEN_N_WEBRTC(P 7300, T 7508): webrtc_private.c: webrtcbin_signaling_state_cb(1186) > webrtc[0x14b41f8] [SignalingState] is changed to [HAVE_LOCAL_OFFER] 11-01 10:35:28.427 D/TIZEN_N_WEBRTC(P 7300, T 7508): webrtc_private.c: post_signaling_state_change_cb_in_idle(804) > webrtc[0x14b41f8] signaling state will be changed to [1], source id[55] 11-01 10:35:28.428 D/TIZEN_N_WEBRTC(P 7300, T 7508): webrtc_private.c: __webrtcbin_ice_gathering_state_cb(1205) > webrtc[0x14b41f8] [IceGatheringState] is changed to [GATHERING] 11-01 10:35:28.428 D/TIZEN_N_WEBRTC(P 7300, T 7508): webrtc_private.c: __post_ice_gathering_state_change_cb_in_idle(824) > webrtc[0x14b41f8] ICE gathering state will be changed to [1], source id[56] 11-01 10:35:28.427 W/GST_LOG (P 7300, T 7508): INFO: Following log entry could not be sorted and is out of order. 11-01 10:35:28.427 W/GST_LOG (P 7300, T 7508): 0:01:13.627623363 0x130be50 TRACE webrtcbin gstwebrtcbin.c:5976:_set_description_task: notify signaling-state from have-local-offer to have-local-offer 11-01 10:35:28.427 W/GST_LOG (P 7300, T 7508): 0:01:13.627731919 0x130be50 TRACE webrtcbin gstwebrtcbin.c:1132:_collate_ice_gathering_states: transceiver 0x13100a0 has no mid 11-01 10:35:28.427 W/GST_LOG (P 7300, T 7508): 0:01:13.627760882 0x130be50 TRACE webrtcbin gstwebrtcbin.c:1145:_collate_ice_gathering_states: transceiver 0x13100a0 gathering state: 0x1 11-01 10:35:28.427 W/GST_LOG (P 7300, T 7508): 0:01:13.627783011 0x130be50 TRACE webrtcbin gstwebrtcbin.c:1132:_collate_ice_gathering_states: transceiver 0x1310140 has no mid 11-01 10:35:28.427 W/GST_LOG (P 7300, T 7508): 0:01:13.627806159 0x130be50 TRACE webrtcbin gstwebrtcbin.c:1145:_collate_ice_gathering_states: transceiver 0x1310140 gathering state: 0x1 11-01 10:35:28.427 W/GST_LOG (P 7300, T 7508): 0:01:13.627826419 0x130be50 TRACE webrtcbin gstwebrtcbin.c:1166:_collate_ice_gathering_states: ICE gathering state: 0x2 11-01 10:35:28.427 W/GST_LOG (P 7300, T 7508): 0:01:13.627844882 0x130be50 TRACE webrtcbin gstwebrtcbin.c:1170:_collate_ice_gathering_states: returning gathering 11-01 10:35:28.427 W/GST_LOG (P 7300, T 7508): 0:01:13.627869826 0x130be50 INFO webrtcbin gstwebrtcbin.c:1363:_update_and_notify_ice_gathering_state: ICE gathering state change from new(0) to gathering(1) 11-01 10:35:28.428 W/GST_LOG (P 7300, T 7508): 0:01:13.627929678 0x130be50 TRACE webrtcbin gstwebrtcbin.c:1040:_collate_ice_connection_states: transceiver 0x13100a0 has no mid 11-01 10:35:28.428 W/GST_LOG (P 7300, T 7508): 0:01:13.627951622 0x130be50 TRACE webrtcbin gstwebrtcbin.c:1040:_collate_ice_connection_states: transceiver 0x1310140 has no mid 11-01 10:35:28.428 W/GST_LOG (P 7300, T 7508): 0:01:13.627972030 0x130be50 TRACE webrtcbin gstwebrtcbin.c:1061:_collate_ice_connection_states: ICE connection state: 0x0 11-01 10:35:28.428 W/GST_LOG (P 7300, T 7508): 0:01:13.627991159 0x130be50 TRACE webrtcbin gstwebrtcbin.c:1080:_collate_ice_connection_states: returning new 11-01 10:35:28.428 W/GST_LOG (P 7300, T 7508): 0:01:13.628013178 0x130be50 TRACE webrtcbin gstwebrtcbin.c:1216:_collate_peer_connection_states: transceiver 0x13100a0 has no mid 11-01 10:35:28.428 W/GST_LOG (P 7300, T 7508): 0:01:13.628033104 0x130be50 TRACE webrtcbin gstwebrtcbin.c:1216:_collate_peer_connection_states: transceiver 0x1310140 has no mid 11-01 10:35:28.428 W/GST_LOG (P 7300, T 7508): 0:01:13.628055307 0x130be50 TRACE webrtcbin gstwebrtcbin.c:1284:_collate_peer_connection_states: ICE connection state: 0x0. DTLS connection state: 0x0 11-01 10:35:28.428 W/GST_LOG (P 7300, T 7508): 0:01:13.628073770 0x130be50 TRACE webrtcbin gstwebrtcbin.c:1314:_collate_peer_connection_states: returning new 11-01 10:35:28.440 D/LIBNICE_AGENT(P 7300, T 7643): agent.c: agent_recv_message_unlocked(4421) > Agent 0x1563000: agent_recv_message_unlocked returned -1, errno (104) : Connection reset by peer 11-01 10:35:28.440 D/LIBNICE_AGENT(P 7300, T 7643): agent.c: component_io_cb(6057) > component_io_cb: 0x1563000: error receiving message

Any design considerations/constraints Explain in detail how you would like to integrate our SDK into your solution

If you would not like to open an issue to discuss your solution in open-platform, please email your question to kinesis-video-support@amazon.com

disa6302 commented 1 year ago

@yh8004kim ,

I dont think I understand. Our SDK does not use libnice. We have our own ICE implementation following the RFCs. Feel free to reopen if you have more clarifying information.