SessionId in Websocket controller

54 views
Skip to first unread message

Gregor Féng

unread,
May 30, 2014, 9:18:10 PM5/30/14
to chica...@googlegroups.com
Hi all,

I experiment with websocket controller and most worked so far. I can
send messages between chicago boss and different browsers. So far, so
good. What I'm missing yet is the »SessionId«, that is always
»undefined«. I'm using version 0.8.12 and the source of the (very
simple) websocket is as follow:

------------------------------
-module(spw_msgs_websocket, [Req, SessionId]).

-behaviour(boss_service_handler).

-export([
handle_broadcast/2,
handle_close/4,
handle_incoming/4,
handle_join/3,
init/0,
terminate/2
]).

init() ->
io:format("-----init~n", []),
{ok, []}.

handle_join(_URL, _Pid, State) ->
{noreply, State}.

handle_close(_Reason, _URL, _Pid, State) ->
{noreply, State}.

handle_incoming(_URL, Pid, Message, State) ->
Pid ! {text, ["Answer to: " ++ Message]},
{noreply, State}.

handle_broadcast(_Message, State) ->
{noreply, State}.

terminate(_Reason, _State) ->
ok.
------------------------------

In the boss configuration is cowboy set. What's wrong with my setup?

Thanks people!

Gregor Féng

unread,
Jun 10, 2014, 1:42:51 PM6/10/14
to chica...@googlegroups.com
Hello,

nobody else with this problem or know the solution?
> --
> You received this message because you are subscribed to the Google Groups "ChicagoBoss" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to chicagoboss...@googlegroups.com.
> Visit this group at http://groups.google.com/group/chicagoboss.
> To view this discussion on the web visit https://groups.google.com/d/msgid/chicagoboss/20140531011806.GA44434%40evilAtWork.net.
> For more options, visit https://groups.google.com/d/optout.

Igor Clark

unread,
Jun 10, 2014, 6:13:03 PM6/10/14
to chica...@googlegroups.com, ml-chicagob...@evilatwork.net
Hi Gregor, I had a similar problem once before. It seemed to happen when the JS which started a WS connection was only in a static HTML file. It seemed that the session wasn't started, and the session cookie consequently wasn't sent, until the browser had actually accessed a CB controller URL. So I made an empty controller that was served from / and included the HTML for the page in its template rather than in a static HTML file, and from then on the websocket handler received a SessionID. Maybe that'll work for you too.

Cheers,
Igor

Gregor Féng

unread,
Jun 11, 2014, 6:35:01 AM6/11/14
to chica...@googlegroups.com
Hi,

> Hi Gregor, I had a similar problem once before. It seemed to happen when
> the JS which started a WS connection was only in a static HTML file. It
> seemed that the session wasn't started, and the session cookie consequently
> wasn't sent, until the browser had actually accessed a CB controller URL.
> So I made an empty controller that was served from / and included the HTML
> for the page in its template rather than in a static HTML file, and from
> then on the websocket handler received a SessionID. Maybe that'll work for
> you too.

thank you, I'll look in that way ...


>
> Cheers,
> Igor
Reply all
Reply to author
Forward
0 new messages