LiveView connection parameters get lost?


Working on an experimental marriage between LiveView and a front-end JS library called Webix. For this, I am trying to pass an additional parameter (_access_token) to the server on liveConnect.connect(), for further processing during mount/3 (using get_connect_params(socket)) . This works fine the first time, but on subsequent ‘mounts’ the only params that is retained is csrf_token, and my _access_token param gets reset to nil.


let liveSocket = new LiveSocket("/live", Socket,
{params: {_csrf_token: csrfToken, _access_token: accessToken},
 hooks: {app: appHook}})


#inside def mount/3 - first time
 get_connect_params(socket)  #=> %{"_access_token" => "123", "_csrf_token" => "XYZ"}

#inside def mount/3 - second time and beyond
 get_connect_params(socket)  #=> %{"_access_token" => nil, "_csrf_token" => "XYZ"}

Is there some special reason why it works like this? Why does only some info get retained? Or maybe I should discard the LiveView overhead and just work with websockets directly (I sure do love bypassing the whole JSON API layer).

Being a LiveView beginner myself I don’t have anything very useful to add, other than to say that is definitely odd. I’m doing exactly the same thing, and I get what I would expect, which is mount being called twice. get_connect_params returns nil on the first (static rendering) mount call, and has the added connect params from the js LiveSocket creation on the subsequent (LiveSocket) call. I’ve never seen any of my connection params being nilled out like that.