Photon peer disconnect & reconnect

Hi! How to do reconnect right way, for example

var peer = new Photon.PhotonPeer(URL_SERVER);
var connectButton = function () { peer.connect() };
var disconnectButton = function () { peer.disconnect() };
When I'm trying to connect again after disconnect order - nothing happens. I have manually recreate photon peer and connect with new peer.


  • Hi,
    This is probably a bug. The reason is unclear now, connect() creates new Websocket but it fails to connect on same peer.
    Please recreate peer until that get fixed. The only possible drawback of such workaround may be some mess in code.
    Looks like all js Photon products recreate peer.
  • Sergiy
    edited August 2015
    so, I checked source JS code, looks like if I'm calling connect after disconnect again, peer gets new sessionId and compares with the stored old value, as I understand, sessionId value should be set to undefined after disconnect, after such fix, peer can reconnect to the same Websocket without recreation.
  • Many thanks for finding this out.
    We will publish the fix in next sdk update.