it should work like you did, since you dont pattern match on Reason
when timeout happen Reason should be equal to {normal, timeout}.can you check your cowboy version, websocket was made for cowboy 0.9.0 if i recall, if your cowboy version is different you should stick to revert 0.9.0 it should work better since there is a small change in cowboy API for websocket. 2015-02-09 21:59 GMT+08:00 Mert Öztürk <[email protected]>: > Hello Chan, > > I already changed the boss.config file before and now i check > boss_mochicow handler and it is the same as you sent. > My handle close looks like this; > > handle_close(Reason, ServiceName, WebSocketId, State) -> > #state{users=Users} = State, > io:format("ServiceName ~p, WebSocketId ~p, SessiondId ~p, close for > Reason ~p~n", > [ServiceName, WebSocketId, SessionId, Reason]), > [{A,B,C,D,E,F,G,H,I,J,K,L,M,N}] = > boss_db:find(ip_database,[{web_socket_id,'equals',WebSocketId}]), > boss_db:delete(B), > {noreply, #state{users=dict:erase(WebSocketId, Users)}}. > > Do i have to add it here? > > Thanks > Mert > > 9 Şubat 2015 Pazartesi 15:42:22 UTC+2 tarihinde mihawk yazdı: >> >> should do the job, as far as i know >> >> in boss.config >> add {websocket_timeout, 5*60} >> >> here the link >> https://github.com/ChicagoBoss/ChicagoBoss/blob/ >> master/src/boss/boss_mochicow_handler.erl#L38 >> >> you should receive >> {normal, timeout} >> >> >> 2015-02-09 20:42 GMT+08:00 Mert Öztürk <[email protected]>: >> >>> Hello Chan, >>> >>> I am using latest Chicagoboss version 0.8.13 and your websocket example >>> for your app draw. >>> https://github.com/mihawk/draw/blob/master/apps/draw/ >>> src/websocket/draw_websocket_test_websocket.erl >>> >>> 95% handle_close is working fine but sometimes it doesnt catch browser >>> exits. >>> In my app i have two databases. One of them is mock which i use it for >>> online users and the other one is MongoDB which is for returning clients. >>> When a client opens the app in browser, client is saved on boss_db mock >>> with my parameters. >>> When client closes browser window, handle close function deletes the >>> user from boss_db mock. So i can use the boss_db mock to give service to >>> online clients without any registeration. >>> >>> So the problem is handle close sometimes doesnt work and client can not >>> be deleted from boss_db mock. That client still looks online and try to >>> retrieve messages although client doesnt exist anymore. >>> So i decided to implement timeout to the user which doesnt have any >>> activity within 5 minutes and get deleted from boss_db mock. >>> >>> Is it possible? >>> >>> Thanks >>> Mert >>> >>> 9 Şubat 2015 Pazartesi 14:32:45 UTC+2 tarihinde mihawk yazdı: >>>> >>>> hi Mert, >>>> >>>> can you check if handle_close work for a given version of CB ? >>>> >>>> 2015-02-09 19:37 GMT+08:00 Mert Öztürk <[email protected]>: >>>> >>>>> Hello, >>>>> >>>>> I am having a little bit of trouble with the websocket close function. >>>>> When the client closes (exits) my app on browser, my websocket handle >>>>> close >>>>> function doesnt work properly and i can not delete the user from my mock >>>>> boss_db database.This is a big problem for me because that client is still >>>>> seen as online and system tries to send messages to that client although >>>>> client doesnt exist. >>>>> >>>>> I found this from older posts but i think the link is broken. >>>>> >>>>> https://groups.google.com/forum/#!msg/chicagoboss/pKx7x4F19N >>>>> k/6FLpvMGMbf4J >>>>> >>>>> Is there any example of websocket with a timeout added? >>>>> >>>>> Thanks >>>>> Mert >>>>> >>>>> -- >>>>> 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 [email protected]. >>>>> 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/62ea4065-ac34-43f8-807b-e1bbf9797d46%40googl >>>>> egroups.com >>>>> <https://groups.google.com/d/msgid/chicagoboss/62ea4065-ac34-43f8-807b-e1bbf9797d46%40googlegroups.com?utm_medium=email&utm_source=footer> >>>>> . >>>>> For more options, visit https://groups.google.com/d/optout. >>>>> >>>> >>>> -- >>> 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 [email protected]. >>> 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/78bd65a6-4b6f-494c-813e-029fe4123a89% >>> 40googlegroups.com >>> <https://groups.google.com/d/msgid/chicagoboss/78bd65a6-4b6f-494c-813e-029fe4123a89%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> -- > 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 [email protected]. > 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/2da54505-d78b-4a3c-bfb9-b2c082516ea8%40googlegroups.com > <https://groups.google.com/d/msgid/chicagoboss/2da54505-d78b-4a3c-bfb9-b2c082516ea8%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- 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 [email protected]. 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/CAB-Ofh%3DjtUz30%3DnwKS6y-F_zNZ%2B7aPYTWzqEh21qxGj2duMdAg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
