question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Signal taking very long

See original GitHub issue

I’m having some issues with the signaling phase, as it takes randomly a really long time (> 10 sec) or, worse, it never actually gets any data.

Basically, I’m following the basic tutorial, and then I’m doing this:

peer.on('signal', data => {
  console.log('data', data);
  // omitted
});

For testing I’m using the Stun server from Google. In production I will rely on another more reliable stun server (as it is suggested not to use the one by Google in production).

I have also tried with some other stun servers from the following list. Unfortunately the problem persists.

With trickle set to false, I get the following messages in the console of the initiator:

[2018-11-16T15:32:28.988Z] SimplePeer debugger: "starting batched negotiation"
[2018-11-16T15:32:28.989Z] SimplePeer debugger: "start negotiation"
[2018-11-16T15:32:29.000Z] SimplePeer debugger: "signalingStateChange %s"
[2018-11-16T15:32:29.000Z] SimplePeer debugger: "createOffer success"
[2018-11-16T15:32:29.002Z] SimplePeer debugger: "iceStateChange (connection: %s) (gathering: %s)"

And most of the times it won’t proceed further as no code is retrieved from the signal event.

With trickle set to true, in the console of the initiator I get this:

[2018-11-16T16:46:23.210Z] SimplePeer debugger: "starting batched negotiation"
[2018-11-16T16:46:23.212Z] SimplePeer debugger: "start negotiation"
[2018-11-16T16:46:23.223Z] SimplePeer debugger: "signalingStateChange %s"
[2018-11-16T16:46:23.223Z] SimplePeer debugger: "createOffer success"
[2018-11-16T16:46:23.224Z] SimplePeer debugger: "signal"
[2018-11-16T16:46:23.225Z] Signal code response .
[2018-11-16T16:46:23.226Z] Started as initiator
[2018-11-16T16:46:23.226Z] SimplePeer debugger: "iceStateChange (connection: %s) (gathering: %s)"
[2018-11-16T16:46:23.227Z] Signal code response 
                        - candidate: candidate:924416723 1 udp 2113937151 192.168.86.74 55048 typ host generation 0 ufrag FHB8 network-cost 999;
                        - sdpMLineIndex: 0;
                        - sdpMid: data.
[2018-11-16T16:46:23.228Z] Started as initiator
[2018-11-16T16:46:23.265Z] Signal code response 
                        - candidate: candidate:842163049 1 udp 1677729535 MY.CORR.ECT.IP 55048 typ srflx raddr 192.168.86.74 rport 55048 generation 0 ufrag FHB8 network-cost 999;
                        - sdpMLineIndex: 0;
                        - sdpMid: data.
[2018-11-16T16:46:23.266Z] Started as initiator
[2018-11-16T16:46:23.268Z] SimplePeer debugger: "signal()"
[2018-11-16T16:46:23.282Z] SimplePeer debugger: "signal()"
[2018-11-16T16:46:23.290Z] SimplePeer debugger: "flushing sender queue"
[2018-11-16T16:46:23.290Z] SimplePeer debugger: "negotiate"
[2018-11-16T16:46:23.291Z] SimplePeer debugger: "signalingStateChange %s"
[2018-11-16T16:46:23.306Z] SimplePeer debugger: "iceStateChange (connection: %s) (gathering: %s)"
[2018-11-16T16:46:23.307Z] SimplePeer debugger: "iceStateChange (connection: %s) (gathering: %s)"
[2018-11-16T16:46:23.307Z] SimplePeer debugger: "iceStateChange (connection: %s) (gathering: %s)"
[2018-11-16T16:46:23.307Z] SimplePeer debugger: "maybeReady pc %s channel %s"
[2018-11-16T16:46:23.308Z] SimplePeer debugger: "iceStateChange (connection: %s) (gathering: %s)"
[2018-11-16T16:46:23.308Z] SimplePeer debugger: "maybeReady pc %s channel %s"
[2018-11-16T16:46:23.311Z] SimplePeer debugger: "on channel open"
[2018-11-16T16:46:23.311Z] SimplePeer debugger: "maybeReady pc %s channel %s"
[2018-11-16T16:46:23.314Z] SimplePeer debugger: "connect local: %s:%s remote: %s:%s"
[2018-11-16T16:46:23.315Z] SimplePeer debugger: "connect"

In the receiver, I get the following:

[2018-11-16T16:49:20.964Z] SimplePeer debugger: "signal()"
[2018-11-16T16:49:20.968Z] connectionData 
                        - code: {"candidate":{"candidate":"candidate:924416723 1 udp 2113937151 192.168.86.74 52336 typ host generation 0 ufrag EUTJ network-cost 999","sdpMLineIndex":0,"sdpMid":"data"}}.
[2018-11-16T16:49:20.972Z] SimplePeer debugger: "signal()"
[2018-11-16T16:49:20.981Z] SimplePeer debugger: "signalingStateChange %s"
[2018-11-16T16:49:20.987Z] SimplePeer debugger: "flushing sender queue"
[2018-11-16T16:49:20.987Z] SimplePeer debugger: "negotiate"
[2018-11-16T16:49:20.987Z] SimplePeer debugger: "signalingStateChange %s"
[2018-11-16T16:49:20.987Z] SimplePeer debugger: "signal"
[2018-11-16T16:49:20.989Z] SimplePeer debugger: "iceStateChange (connection: %s) (gathering: %s)"
[2018-11-16T16:49:21.004Z] SimplePeer debugger: "iceStateChange (connection: %s) (gathering: %s)"
[2018-11-16T16:49:21.007Z] SimplePeer debugger: "iceStateChange (connection: %s) (gathering: %s)"
[2018-11-16T16:49:21.008Z] SimplePeer debugger: "maybeReady pc %s channel %s"
[2018-11-16T16:49:21.013Z] SimplePeer debugger: "on channel open"
[2018-11-16T16:49:21.013Z] SimplePeer debugger: "maybeReady pc %s channel %s"
[2018-11-16T16:49:21.014Z] connectionData 
                        - code: {"candidate":{"candidate":"candidate:842163049 1 udp 1677729535 MY.CORR.ECT.IP 52336 typ srflx raddr 192.168.86.74 rport 52336 generation 0 ufrag EUTJ network-cost 999","sdpMLineIndex":0,"sdpMid":"data"}}.
[2018-11-16T16:49:21.018Z] SimplePeer debugger: "signal()"
[2018-11-16T16:49:21.021Z] SimplePeer debugger: "connect local: %s:%s remote: %s:%s"
[2018-11-16T16:49:21.022Z] SimplePeer debugger: "connect"
[2018-11-16T16:49:21.023Z] Peer Object 
                        - _id: 367ff3e;
                        - _readableState: {"objectMode":false,"highWaterMark":16384,"buffer":{"head":null,"tail":null,"length":0},"length":0,"pipes":null,"pipesCount":0,"flowing":true,"ended":false,"endEmitted":false,"reading":false,"sync":true,"needReadable":false,"emittedReadable":false,"readableListening":false,"resumeScheduled":true,"destroyed":false,"defaultEncoding":"utf8","awaitDrain":0,"readingMore":false,"decoder":null,"encoding":null};
                        - readable: true;
                        - _events: {};
                        - _eventsCount: 7;
                        - _maxListeners: undefined;
                        - _writableState: {"objectMode":false,"highWaterMark":16384,"finalCalled":false,"needDrain":false,"ending":false,"ended":false,"finished":false,"destroyed":false,"decodeStrings":true,"defaultEncoding":"utf8","length":0,"writing":false,"corked":0,"sync":true,"bufferProcessing":false,"writecb":null,"writelen":0,"bufferedRequest":null,"lastBufferedRequest":null,"pendingcb":0,"prefinished":false,"errorEmitted":false,"bufferedRequestCount":0,"corkedRequestsFree":{"next":null,"entry":null}};
                        - writable: true;
                        - allowHalfOpen: false;
                        - channelName: null;
                        - _isChromium: true;
                        - initiator: false;
                        - channelConfig: {};
                        - config: {"iceServers":[{"urls":"stun:stun.schlund.de"},{"urls":"turn:13.250.13.83:3478?transport=tcp","username":"YzYNCouZM1mhqhmseWk6","credential":"YzYNCouZM1mhqhmseWk6"}]};
                        - constraints: {};
                        - offerConstraints: {};
                        - answerConstraints: {};
                        - sdpTransform: undefined;
                        - streams: [];
                        - trickle: true;
                        - connected: false;
                        - remoteAddress: undefined;
                        - remoteFamily: undefined;
                        - remotePort: undefined;
                        - localAddress: undefined;
                        - localPort: undefined;
                        - _wrtc: {};
                        - _pcReady: false;
                        - _channelReady: false;
                        - _iceComplete: false;
                        - _channel: null;
                        - _pendingCandidates: [{"candidate":"candidate:842163049 1 udp 1677729535 MY.CORR.ECT.IP 52336 typ srflx raddr 192.168.86.74 rport 52336 generation 0 ufrag EUTJ network-cost 999","sdpMLineIndex":0,"sdpMid":"data"}];
                        - _isNegotiating: false;
                        - _batchedNegotiation: false;
                        - _queuedNegotiation: false;
                        - _sendersAwaitingStable: [];
                        - _senderMap: {};
                        - _remoteTracks: [];
                        - _remoteStreams: [];
                        - _chunk: null;
                        - _cb: null;
                        - _interval: null;
                        - _pc: {};
                        - _isReactNativeWebrtc: false;
                        - _onFinishBound: undefined;
                        - _debug: undefined;
                        - address: undefined;
                        - signal: undefined;
                        - _addIceCandidate: undefined;
                        - send: undefined;
                        - addStream: undefined;
                        - addTrack: undefined;
                        - removeTrack: undefined;
                        - removeStream: undefined;
                        - _needsNegotiation: undefined;
                        - negotiate: undefined;
                        - destroy: undefined;
                        - _destroy: undefined;
                        - _setupData: undefined;
                        - _read: undefined;
                        - _write: undefined;
                        - _onFinish: undefined;
                        - _createOffer: undefined;
                        - _createAnswer: undefined;
                        - _onIceStateChange: undefined;
                        - getStats: undefined;
                        - _maybeReady: undefined;
                        - _onInterval: undefined;
                        - _onSignalingStateChange: undefined;
                        - _onIceCandidate: undefined;
                        - _onChannelMessage: undefined;
                        - _onChannelBufferedAmountLow: undefined;
                        - _onChannelOpen: undefined;
                        - _onChannelClose: undefined;
                        - _onTrack: undefined;
                        - _transformConstraints: undefined;
                        - write: undefined;
                        - cork: undefined;
                        - uncork: undefined;
                        - setDefaultEncoding: undefined;
                        - _writev: null;
                        - end: undefined;
                        - _undestroy: undefined;
                        - push: undefined;
                        - unshift: undefined;
                        - isPaused: undefined;
                        - setEncoding: undefined;
                        - read: undefined;
                        - pipe: undefined;
                        - unpipe: undefined;
                        - on: undefined;
                        - addListener: undefined;
                        - resume: undefined;
                        - pause: undefined;
                        - wrap: undefined;
                        - setMaxListeners: undefined;
                        - getMaxListeners: undefined;
                        - emit: undefined;
                        - prependListener: undefined;
                        - once: undefined;
                        - prependOnceListener: undefined;
                        - removeListener: undefined;
                        - removeAllListeners: undefined;
                        - listeners: undefined;
                        - listenerCount: undefined;
                        - eventNames: undefined.

In this second scenario there are a couple of things that I do not totally get, in particular why do I see the connect event in the SimplePeer debug messages, but then if I log the peer Object it states connected: false?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
t-mullencommented, Nov 19, 2018

The fix we added is an ice gathering timeout that only works when trickle is disabled. We’re aware of the limitation for now.

0reactions
ilDoncommented, Nov 19, 2018

I’m happy to confirm that with trickle set to false with the latest code (from github) it’s working again!

I still get the issue mentioned before with trickle set to true (connect event fired when receiver is not actually connected yet). Should I open a new issue or is this one fine?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Signal gets really slow on long Conversations #9930 - GitHub
Performance in a long Chat is drastically Improved with Version 5.20.4. A Message takes around 2-3 seconds now, which i consider "instant".
Read more >
Troubleshoot receiving messages - Signal Support
Signal uses your phone's internet connection for all private communication. The most common reasons why you can't receive messages when your phone is...
Read more >
Is anybody's Signal taking like 7 seconds to send messages?
The standard fix is to delete all your histories. According to r/Signal, it is well established that chat histories are not useful. Please ......
Read more >
All of Signal's file sharing size limits in every version of the app
If you regularly need to send large files over Signal, your best bet is to use the Android app. It has the highest...
Read more >
If your iPhone or iPad is running slow - Apple Support
Even if your device indicates a strong signal, you might need to ... In fact, an app takes longer to open after a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found