Inconsistent from ID in WebRTC Signaling Causing Connection Issues

Correct log:
Signaling: Connecting WS ws://127.0.0.1:22222/lyg/p/12312
Signaling: WS connected.
Signaling: Sending WS data: {“type”:“connect”,“processId”:12312}
Signaling: Receiving message: {“type”:“connect”,“connectionId”:“553188cacd6c4dd687e2679bcd3ac698”,“polite”:true}
Signaling: Receiving message: {“type”:“connect”,“connectionId”:“553188cacd6c4dd687e2679bcd3ac698”,“polite”:true}
Signaling: Receiving message: {“type”:“offer”,“from”:“553188cacd6c4dd687e2679bcd3ac698”,“data”:{“sdp”:“v=0\r\no=- 1763178633083798760 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE 0\r\na=extmap-allow-mixed\r\na=msid-semantic: WMS\r\nm=application 9 UDP/DTLS/SCTP webrtc-datachannel\r\nc=IN IP4 0.0.0.0\r\na=ice-ufrag:iBCm\r\na=ice-pwd:b9gb2zUFgEquU0J8558opsPD\r\na=ice-options:trickle\r\na=fingerprint:sha-256 9B:5F:77:D6:05:E1:CB:2A:B4:52:9B:AB:3D:AF:A4:EC:0A:3F:90:B7:38:ED:BA:50:0F:CE:8D:4D:4B:22:D2:C0\r\na=setup:actpass\r\na=mid:0\r\na=sctp-port:5000\r\na=max-message-size:262144\r\n”,“datetime”:1725440542280,“polite”:true}}
Signaling: Receiving message: {“type”:“candidate”,“connectionId”:“553188cacd6c4dd687e2679bcd3ac698”,“from”:“553188cacd6c4dd687e2679bcd3ac698”,“data”:{“candidate”:“candidate:3425411327 1 udp 2113937151 e8a6a3e1-766e-420c-a861-bf7a6e940bbc.local 56423 typ host generation 0 ufrag iBCm network-cost 999”,“sdpMLineIndex”:“0”,“sdpMid”:0,“datetime”:1725440542282},“to”:“”}
[polite-PeerConnection ConnectionState:New IceConnectionState:New SignalingState:Stable GatheringState:New] this candidate can’t accept on state.
Signaling: Receiving message: {“type”:“candidate”,“connectionId”:“553188cacd6c4dd687e2679bcd3ac698”,“from”:“553188cacd6c4dd687e2679bcd3ac698”,“data”:{“candidate”:“candidate:1510194352 1 udp 33562367 32.108.0.128 22237 typ relay raddr 32.108.0.128 rport 56423 generation 0 ufrag iBCm network-cost 999”,“sdpMLineIndex”:“0”,“sdpMid”:0,“datetime”:1725440542334},“to”:“”}
Signaling: Sending WS data: {“from”:“553188cacd6c4dd687e2679bcd3ac698”,“to”:“”,“type”:“candidate”,“data”:{“connectionId”:“553188cacd6c4dd687e2679bcd3ac698”,“candidate”:“candidate:2390748989 1 udp 2122260223 32.108.0.128 56427 typ host generation 0 ufrag skA7 network-id 1”,“sdpMid”:“0”,“sdpMLineIndex”:0}}
Signaling: Sending WS data: {“from”:“553188cacd6c4dd687e2679bcd3ac698”,“to”:“”,“type”:“answer”,“data”:{“connectionId”:“553188cacd6c4dd687e2679bcd3ac698”,“sdp”:“v=0\r\no=- 1558499560729282144 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE 0\r\na=extmap-allow-mixed\r\na=msid-semantic: WMS\r\nm=application 56427 UDP/DTLS/SCTP webrtc-datachannel\r\nc=IN IP4 32.108.0.128\r\na=candidate:2390748989 1 udp 2122260223 32.108.0.128 56427 typ host generation 0 network-id 1\r\na=ice-ufrag:skA7\r\na=ice-pwd:8FSq+5GPXKscUqsYIOZ7Of/M\r\na=ice-options:trickle\r\na=fingerprint:sha-256 0B:74:AB:B8:70:3A:04:14:70:82:86:2F:39:90:91:8F:3F:1E:C6:B7:D6:B8:CD:4D:15:AA:FB:E1:0B:BC:A0:F6\r\na=setup:active\r\na=mid:0\r\na=sctp-port:5000\r\na=max-message-size:262144\r\n”,“type”:“answer”,“polite”:false}}
Signaling: Sending WS data: {“from”:“553188cacd6c4dd687e2679bcd3ac698”,“to”:“”,“type”:“offer”,“data”:{“connectionId”:“553188cacd6c4dd687e2679bcd3ac698”,“sdp”:"v=0\r\no=- 1558499560729282144 3 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE 0 1\r\na=extmap-allow-mixed\r\na=msid-semantic: WMS\r\nm=application 56427 UDP/DTLS/SCTP webrtc-datachannel\r\nc=IN IP4 32.108.0.128\r\na=candidate:2390748989 1 udp 2122260223 32.108.0.128 56427 typ host generation 0 network-id 1\r\na=ice-ufrag:skA7\r\na=ice-pwd:8FSq+5GPXKscUqsYIOZ7Of/M\r\na=ice-options:trickle\r\na=fingerprint:sha-256 0B:74:AB:B8:70:3A:04:14:70:82:86:2F:39:90:91:8F:3F:1E:C6:B7:D6:B8:CD:4D:15:AA:FB:E1:0B:BC:A0:F6\r\na=setup:actpass\r\na=mid:0\r\na=sctp-port:5000\r\na=max-message-size:262144\r\nm=video 9 UDP/TLS/RTP/SAVPF 120\r\nc=IN IP4 0.0.0.0\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=ice-ufrag:skA7\r\na=ice-pwd:8FSq+5GPXKscUqsYIOZ7Of/M\r\na=ice-options:trickle\r\na=fingerprint:sha-256 0B:74:AB:B8:70:3A:04:14:70:82:86:2F:39:90:91:8F:3F:1E:C6:B7:D6:B8:CD:4D:15:AA:FB:E1:0B:BC:A0:F6\r\na=setup:actpass\r\na=mid:1\r\na=extmap:1 urn:ietf:params:rtp-hdrext:toffset\r\na=extmap:2 ,“type”:“offer”,“polite”:false}}
Signaling: Receiving message: {“type”:“answer”,“from”:“553188cacd6c4dd687e2679bcd3ac698”,“data”:{“sdp”:"v=0\r\no=- 1763178633083798760 3 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE 0 1\r\na=extmap-allow-mixed\r\na=msid-semantic: WMS\r\nm=application 22237 UDP/DTLS/SCTP webrtc-datachannel\r\nc=IN IP4 32.108.0.128\r\na=candidate:3425411327 1 udp 2113937151 e8a6a3e1-766e-420c-a861-bf7a6e940bbc.local 56423 typ host generation 0 network-cost 999\r\na=candidate:1510194352 1 udp 33562367 32.108.0.128 22237 typ relay raddr 32.108.0.128 rport 56423 generation 0 network-cost 999\r\na=ice-ufrag:iBCm\r\na=ice-pwd:b9gb2zUFgEquU0J8558opsPD\r\na=ice-options:trickle\r\na=fingerprint:sha-256 9B:5F:77:D6:05:E1:CB:2A:B4:52:9B:AB:3D:AF:A4:EC:0A:3F:90:B7:38:ED:BA:50:0F:CE:8D:4D:4B:22:D2:C0\r\na=setup:passive\r\na=mid:0\r\na=sctp-port:5000\r\na=max-message-size:262144\r\nm=video 9 UDP/TLS/RTP/SAVPF 120\r\nc=IN IP4 0.0.0.0\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=ice-ufrag:iBCm\r\na=ice-pwd:b9gb2zUFgEquU0J8558opsPD\r\na=ice-options:trickle\r\na=fingerprint:sha-256 9B:5F:77:D6:05:E1:CB:2A:B4:52:9B:AB:3D:AF:A4:EC:0A:3F:90:B7:38:ED:BA:50:0F:CE:8D:4D:4B:22:D2:C0\r\na=setup:passive\r\na=mid:1\r\na=extmap:1 urn:ietf:params:rtp-hdrext:toffset\r\na=extmap:2 ,“datetime”:1725440542537}}
Signaling: Receiving message: {“type”:“disconnect”,“connectionId”:“553188cacd6c4dd687e2679bcd3ac698”}
Signaling: WS connection closed, code: 1005

Incorrect log:
Signaling: Connecting WS ws://127.0.0.1:22222/lyg/p/12312
Signaling: WS connected.
Signaling: Sending WS data: {“type”:“connect”,“processId”:12312}
Signaling: Receiving message: {“type”:“connect”,“connectionId”:“6f983a0eaba344afa80f47f5f82c3ce9”,“polite”:true}
Signaling: Receiving message: {“type”:“connect”,“connectionId”:“dbe335d4fea24846880f2c9c4e9eed0d”,“polite”:true}
Signaling: Receiving message: {“type”:“offer”,“from”:“dbe335d4fea24846880f2c9c4e9eed0d”,“data”:{“sdp”:“v=0\r\no=- 4006397628393390887 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE 0\r\na=extmap-allow-mixed\r\na=msid-semantic: WMS\r\nm=application 9 UDP/DTLS/SCTP webrtc-datachannel\r\nc=IN IP4 0.0.0.0\r\na=ice-ufrag:3Gvn\r\na=ice-pwd:xvSuLOt58Yx7qpWgw4Ffaxdq\r\na=ice-options:trickle\r\na=fingerprint:sha-256 11:91:FB:65:26:2E:80:42:BA:C9:D3:9C:26:BE:77:DD:FB:6C:B1:69:D9:B7:C9:62:99:A7:E4:BF:91:75:80:95\r\na=setup:actpass\r\na=mid:0\r\na=sctp-port:5000\r\na=max-message-size:262144\r\n”,“datetime”:1725440547442,“polite”:true}}
Signaling: Receiving message: {“type”:“candidate”,“connectionId”:“dbe335d4fea24846880f2c9c4e9eed0d”,“from”:“dbe335d4fea24846880f2c9c4e9eed0d”,“data”:{“candidate”:“candidate:3425411327 1 udp 2113937151 e8a6a3e1-766e-420c-a861-bf7a6e940bbc.local 56430 typ host generation 0 ufrag 3Gvn network-cost 999”,“sdpMLineIndex”:“0”,“sdpMid”:0,“datetime”:1725440547444},“to”:“”}
Signaling: Receiving message: {“type”:“candidate”,“connectionId”:“dbe335d4fea24846880f2c9c4e9eed0d”,“from”:“dbe335d4fea24846880f2c9c4e9eed0d”,“data”:{“candidate”:“candidate:1510194352 1 udp 33562367 32.108.0.128 22272 typ relay raddr 32.108.0.128 rport 56430 generation 0 ufrag 3Gvn network-cost 999”,“sdpMLineIndex”:“0”,“sdpMid”:0,“datetime”:1725440547496},“to”:“”}
Signaling: Sending WS data: {“from”:“dbe335d4fea24846880f2c9c4e9eed0d”,“to”:“”,“type”:“candidate”,“data”:{“connectionId”:“dbe335d4fea24846880f2c9c4e9eed0d”,“candidate”:“candidate:2582901301 1 udp 2122260223 32.108.0.128 56434 typ host generation 0 ufrag R7cq network-id 1”,“sdpMid”:“0”,“sdpMLineIndex”:0}}
Signaling: Sending WS data: {“from”:“dbe335d4fea24846880f2c9c4e9eed0d”,“to”:“”,“type”:“answer”,“data”:{“connectionId”:“dbe335d4fea24846880f2c9c4e9eed0d”,“sdp”:"v=0\r\no=- 1009280482480018712 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE 0\r\na=extmap-allow-mixed\r\na=msid-semantic: WMS\r\nm=application 56434 UDP/DTLS/SCTP webrtc-datachannel\r\nc=IN IP4 32.108.0.128\r\na=candidate:2582901301 1 udp 2122260223 32.108.0.128 56434 typ host generation 0 network-id 1\r\na=ice-ufrag:R7cqSignaling: Receiving message: {“type”:“offer”,“from”:“9429562a2fd34694a9214aea70e3feb2”,“data”:{“sdp”:“v=0\r\no=- 5936670438661904978 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE 0\r\na=extmap-allow-mixed\r\na=msid-semantic: WMS\r\nm=application 22229 UDP/DTLS/SCTP webrtc-datachannel\r\nc=IN IP4 32.108.0.128\r\na=candidate:3425411327 1 udp 2113937151 b9502272-c47f-4a32-a209-fb732753ec20.local 56400 typ host generation 0 network-cost 999\r\na=candidate:1510194352 1 udp 33562367 32.108.0.128 22229 typ relay raddr 32.108.0.128 rport 56400 generation 0 network-cost 999\r\na=ice-ufrag:LfNx\r\na=ice-pwd:VyClqTUwGBVbLciAglRZmFU8\r\na=ice-options:trickle\r\na=fingerprint:sha-256 98:B5:7D:FF:05:5F:C5:D1:E1:7B:E8:1B:C2:92:FE:31:BA:45:D2:59:C6:61:4F:E8:4A:FE:56:58:E4:BB:7B:03\r\na=setup:actpass\r\na=mid:0\r\na=sctp-port:5000\r\na=max-message-size:262144\r\n”,“datetime”:1725440551594,“polite”:true}}
Signaling: Receiving message: {“type”:“offer”,“from”:“9429562a2fd34694a9214aea70e3feb2”,“data”:{“sdp”:“v=0\r\no=- 5936670438661904978 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE 0\r\na=extmap-allow-mixed\r\na=msid-semantic: WMS\r\nm=application 22229 UDP/DTLS/SCTP webrtc-datachannel\r\nc=IN IP4 32.108.0.128\r\na=candidate:3425411327 1 udp 2113937151 b9502272-c47f-4a32-a209-fb732753ec20.local 56400 typ host generation 0 network-cost 999\r\na=candidate:1510194352 1 udp 33562367 32.108.0.128 22229 typ relay raddr 32.108.0.128 rport 56400 generation 0 network-cost 999\r\na=ice-ufrag:LfNx\r\na=ice-pwd:VyClqTUwGBVbLciAglRZmFU8\r\na=ice-options:trickle\r\na=fingerprint:sha-256 98:B5:7D:FF:05:5F:C5:D1:E1:7B:E8:1B:C2:92:FE:31:BA:45:D2:59:C6:61:4F:E8:4A:FE:56:58:E4:BB:7B:03\r\na=setup:actpass\r\na=mid:0\r\na=sctp-port:5000\r\na=max-message-size:262144\r\n”,“datetime”:1725440557593,“polite”:true}}
Signaling: Receiving message: {“type”:“offer”,“from”:“9429562a2fd34694a9214aea70e3feb2”,“data”:{“sdp”:“v=0\r\no=- 5936670438661904978 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE 0\r\na=extmap-allow-mixed\r\na=msid-semantic: WMS\r\nm=application 22229 UDP/DTLS/SCTP webrtc-datachannel\r\nc=IN IP4 32.108.0.128\r\na=candidate:3425411327 1 udp 2113937151 b9502272-c47f-4a32-a209-fb732753ec20.local 56400 typ host generation 0 network-cost 999\r\na=candidate:1510194352 1 udp 33562367 32.108.0.128 22229 typ relay raddr 32.108.0.128 rport 56400 generation 0 network-cost 999\r\na=ice-ufrag:LfNx\r\na=ice-pwd:VyClqTUwGBVbLciAglRZmFU8\r\na=ice-options:trickle\r\na=fingerprint:sha-256 98:B5:7D:FF:05:5F:C5:D1:E1:7B:E8:1B:C2:92:FE:31:BA:45:D2:59:C6:61:4F:E8:4A:FE:56:58:E4:BB:7B:03\r\na=setup:actpass\r\na=mid:0\r\na=sctp-port:5000\r\na=max-message-size:262144\r\n”,“datetime”:1725440563592,“polite”:true}}
Signaling: Receiving message: {“type”:“offer”,“from”:“9429562a2fd34694a9214aea70e3feb2”,“data”:{“sdp”:“v=0\r\no=- 5936670438661904978 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE 0\r\na=extmap-allow-mixed\r\na=msid-semantic: WMS\r\nm=application 22229 UDP/DTLS/SCTP webrtc-datachannel\r\nc=IN IP4 32.108.0.128\r\na=candidate:3425411327 1 udp 2113937151 b9502272-c47f-4a32-a209-fb732753ec20.local 56400 typ host generation 0 network-cost 999\r\na=candidate:1510194352 1 udp 33562367 32.108.0.128 22229 typ relay raddr 32.108.0.128 rport 56400 generation 0 network-cost 999\r\na=ice-ufrag:LfNx\r\na=ice-pwd:VyClqTUwGBVbLciAglRZmFU8\r\na=ice-options:trickle\r\na=fingerprint:sha-256 98:B5:7D:FF:05:5F:C5:D1:E1:7B:E8:1B:C2:92:FE:31:BA:45:D2:59:C6:61:4F:E8:4A:FE:56:58:E4:BB:7B:03\r\na=setup:actpass\r\na=mid:0\r\na=sctp-port:5000\r\na=max-message-size:262144\r\n”,“datetime”:1725440569593,“polite”:true}}
Signaling: Receiving message: {“type”:“offer”,“from”:“9429562a2fd34694a9214aea70e3feb2”,“data”:{“sdp”:“v=0\r\no=- 5936670438661904978 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE 0\r\na=extmap-allow-mixed\r\na=msid-semantic: WMS\r\nm=application 22229 UDP/DTLS/SCTP webrtc-datachannel\r\nc=IN IP4 32.108.0.128\r\na=candidate:3425411327 1 udp 2113937151 b9502272-c47f-4a32-a209-fb732753ec20.local 56400 typ host generation 0 network-cost 999\r\na=candidate:1510194352 1 udp 33562367 32.108.0.128 22229 typ relay raddr 32.108.0.128 rport 56400 generation 0 network-cost 999\r\na=ice-ufrag:LfNx\r\na=ice-pwd:VyClqTUwGBVbLciAglRZmFU8\r\na=ice-options:trickle\r\na=fingerprint:sha-256 98:B5:7D:FF:05:5F:C5:D1:E1:7B:E8:1B:C2:92:FE:31:BA:45:D2:59:C6:61:4F:E8:4A:FE:56:58:E4:BB:7B:03\r\na=setup:actpass\r\na=mid:0\r\na=sctp-port:5000\r\na=max-message-size:262144\r\n”,“datetime”:1725440575592,“polite”:true}}
Signaling: Receiving message: {“type”:“offer”,“from”:“9429562a2fd34694a9214aea70e3feb2”,“data”:{“sdp”:“v=0\r\no=- 5936670438661904978 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE 0\r\na=extmap-allow-mixed\r\na=msid-semantic: WMS\r\nm=application 22229 UDP/DTLS/SCTP webrtc-datachannel\r\nc=IN IP4 32.108.0.128\r\na=candidate:3425411327 1 udp 2113937151 b9502272-c47f-4a32-a209-fb732753ec20.local 56400 typ host generation 0 network-cost 999\r\na=candidate:1510194352 1 udp 33562367 32.108.0.128 22229 typ relay raddr 32.108.0.128 rport 56400 generation 0 network-cost 999\r\na=ice-ufrag:LfNx\r\na=ice-pwd:VyClqTUwGBVbLciAglRZmFU8\r\na=ice-options:trickle\r\na=fingerprint:sha-256 98:B5:7D:FF:05:5F:C5:D1:E1:7B:E8:1B:C2:92:FE:31:BA:45:D2:59:C6:61:4F:E8:4A:FE:56:58:E4:BB:7B:03\r\na=setup:actpass\r\na=mid:0\r\na=sctp-port:5000\r\na=max-message-size:262144\r\n”,“datetime”:1725440581494,“polite”:true}}
Signaling: Receiving message: {“type”:“disconnect”,“connectionId”:“9429562a2fd34694a9214aea70e3feb2”}
Signaling: WS connection closed, code: 1005 As you can see, in the incorrect log, the from ID changes unexpectedly, but the system continues using the old ID for sending messages, which disrupts the connection process. I’m looking for insights into why this ID change might be happening and how to prevent this issue.