meetecho / janus-gateway

Janus WebRTC Server
https://janus.conf.meetecho.com
GNU General Public License v3.0
8.11k stars 2.46k forks source link

destroyOnUnload --> destroySession don't post destroy request #1793

Closed cyb3rcod3 closed 4 years ago

cyb3rcod3 commented 4 years ago

Test Browser: Firefox 69.0.1 (64 bit) Webpage: https://janus.conf.meetecho.com/videocalltest.html

The problem is inside janus.js -> destroySession when it's triggered by destroyOnUnload before close/reload webpage.

The post request never start and log in janus gateway server don't show any incoming api request for destroy session.

If i add a wait pause of 200ms immediately after Janus.httpAPICall in destroySession the post request is execute successfully as log destroy message show.

lminiero commented 4 years ago

Adding a pause will NOT send the request most of the times, because onbeforeunload can only perform synchronous requests before closing the page. A synchronous HTTP request is exactly what we try to do in janus.js. If the request is not sent, it might be the browser closing the page sooner than expected. You can try overriding the browser callback and perform the request yourself, which janus.js allows. Closing.