wf:state/1 and possible websockets

22 views
Skip to first unread message

Stuart Thackray

unread,
May 6, 2015, 2:49:06 PM5/6/15
to nitro...@googlegroups.com
Hi,

  This is a complicated question and quite random problem. But think have simulated the situation.

  Hopefully someone else has experienced it.

 I have a button that sends an email with a code. then the person submits the code on the webpage. 

  The code is stored using wf:state/2 (I release the state is stored on the page). 

  So click button send code then enter code and press another button.

 The code always looks ok to the person using it i.e. buttons are disabled and enabled as per javascript of the module.
 
  The problem is that wf:state/1 returns undefined some of the times. 

  I am don't see any javascript errors. As I mentioned it is very difficult to simulate but it seems that before the websockets upgrades the button on the page is pressed and an email is sent, then when code is entered the wf:state returns undefined. 
 While if you wait for the page to load and the javascript console says Websockets Enabled then pressing the button to send email correctly stores the state correctly.

  For additional information I have added the following to yaws_simple_bridge_anchor line 17 " error_logger:info_msg("~pUpgrade:~p", [?MODULE, Upgrade]),"

When it doesn't work 

=INFO REPORT==== 6-May-2015::20:16:08 ===
yaws_simple_bridge_anchorUpgrade:"websocket"
=INFO REPORT==== 6-May-2015::20:16:09 ===
yaws_simple_bridge_anchorUpgrade:undefined
This seems to be related to when the button is pressed on page.


When it does work 
=INFO REPORT==== 6-May-2015::20:39:49 ===
yaws_simple_bridge_anchorUpgrade:"websocket"


 So after trying to explain the situation fully. Is there a means to turn off websockets ? to confirm the problem (this is a full webpage with lot of javascript/css/images etc going through websocket so don't expect that supplying a sample page would work very well especially if you are running it locally). 

 Has anyone experienced this problem and maybe know of a work around or the issue?

 Or can someone using yaws, last release of nitrogen, and running the webserver remotely confirm it is something with my setup?

  Regards,
Stuart


Jesse Gumm

unread,
May 7, 2015, 11:48:33 AM5/7/15
to nitrogenweb
Hi Stuart,

Thanks for reporting this. This is an interesting problem indeed. To
disable websockets, you just want to modify one of the last lines of
nitrogen.js, and comment out the line calling
Nitrogen.$attempt_websockets()

This line: https://github.com/nitrogen/nitrogen_core/blob/master/www/nitrogen.js#L1362

If you comment that out, the client will never attempt to upgrade
websockets at all.

I'm curious if you can confirm if this is fixed without websockets. If
so, then I'll need to make sure that that state information isn't lost
during the upgrade (I thought I had that fully fixed, but I have some
ideas on how to simulate this).

Thanks again and please let me know,

-Jesse
> --
> You received this message because you are subscribed to the Google Groups
> "Nitrogen Project / The Nitrogen Web Framework for Erlang" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to nitrogenweb...@googlegroups.com.
> To post to this group, send email to nitro...@googlegroups.com.
> Visit this group at http://groups.google.com/group/nitrogenweb.
> For more options, visit https://groups.google.com/d/optout.



--
Jesse Gumm
Owner, Sigma Star Systems
414.940.4866 || sigma-star.com || @jessegumm

Stuart Thackray

unread,
May 8, 2015, 2:53:23 AM5/8/15
to nitro...@googlegroups.com

Thanks very much Jesse,

  I will let you know regarding when I have had a chance to do a setup and test.

  From what I found using session rather than state I can't make this situation occur.

Regards,
Stuart
Reply all
Reply to author
Forward
0 new messages