Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iceRestart on createoffer not working #101

Open
slootmaekersdirk opened this issue Oct 24, 2023 · 1 comment
Open

iceRestart on createoffer not working #101

slootmaekersdirk opened this issue Oct 24, 2023 · 1 comment

Comments

@slootmaekersdirk
Copy link

Hello,

I'm implementing iceRestart when the connection of onIceStateChange() goes to disconnect/failed.
In our case this can happen, while on the phone, we switch from ethernet to wifi, or in general switch IP addresses.

So I need to implement iceRestart to re-negotiate the ice candidates.
I can force a new CreateOffer with iceRestart:true and I get new icecandidates.
at the end a new 'invite' is send to the websocket, notifying the webrtc signalling server of Amazon Connect.

The problem is that it is not reacting well to sending an 'invite' again on a session that is already ongoing.

I receive a 'BAD_REQUEST' from the signalling websocket :

{"connectionId":"99b1dc8c-01c4-44aa-xxxxxxx","jsonRpcMsg":{"id":"ea012284-7d85-4c14-969f-xxxxxx","jsonrpc":"2.0","error":{"code":400,"data":{"errorCause":"BAD_REQUEST"},"message":"Error"}}}"

My questions, is it possible to have an iceRestart with this library, and am I missing something why it is not working?
For completeness the initial createOffer flow and and the restartIce Flow are exactly the same. instead of using an 'invite' should i use another method in this case so amazon connect signaling server does not react with a BAD_REQUEST?

thanks for the assistance,

@slootmaekersdirk
Copy link
Author

Here is the change of the onicestatechange() what I have implemented

onIceStateChange(evt) {
if (evt.currentTarget.iceConnectionState == 'disconnected') {
this.logger.info('Lost ICE connection');
this._rtcSession._sessionReport.iceConnectionsLost += 1;
setTimeout(()=>this.transit(new CreateOfferState2(this._rtcSession)),4000);
}
if (evt.currentTarget.iceConnectionState == 'connected') {
this.logger.info('ICE connected');
this._rtcSession._sessionReport.iceConnectionsLost = 0;
}

}

And here is the createOfferState2, with the ice restart parameter

export class CreateOfferState2 extends RTCSessionState {
onEnter() {
var self = this;
var stream = self._rtcSession._localStream;
self._rtcSession._pc.addStream(stream);
self._rtcSession._onLocalStreamAdded(self._rtcSession, stream);
self._rtcSession._pc.createOffer({iceRestart:true,offerToReceiveAudio:true,offerToReceiveVideo:false}).then(rtcSessionDescription => {
self._rtcSession._localSessionDescription = rtcSessionDescription;
self._rtcSession._sessionReport.createOfferFailure = false;
self.transit(new SetLocalSessionDescriptionState(self._rtcSession));
}).catch(e => {
self.logger.error('CreateOffer2 failed', e);
self._rtcSession._sessionReport.createOfferFailure = true;
self.transit(new FailedState(self._rtcSession, RTC_ERRORS.CREATE_OFFER_FAILURE));
});
}
get name() {
return "CreateOfferState2";
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant