hatzisn Expert Licensed User Longtime User Oct 27, 2022 #1 I tried today for the first time to use a session object in websocket and I keep getting this error: java.lang.RuntimeException: Object should first be initialized (HttpSession). Click to expand... I searched the forum and found the solutions in: jServer v4.0 - Based on Jetty 11 Starting from B4J v9.80 this library is included as an internal library. Old library: https://www.b4x.com/android/forum/threads/141323/#content This is a new version of jServer. It is based on Jetty 11. Previous versions were based on an early version of Jetty 9. There were many improvements in... www.b4x.com and in safari session variables in b4j v4 Hi i have problems with sessions variables with safari after upgrade to version 4. it seems that browser lose values. Chrome and firefox works correctly. In safari i have the accept cookies and data from all sites active. can anyone help me? www.b4x.com I implemented them but I keep getting this error. I even tried a handler which is called at runtime when the websocket is connected (hidloc is a hidden control which gets the window.location; ) with this code (the handler Handle sub is the same as the filter's sub): B4X: Dim hj As HttpJob hj.Initialize("", Me) Dim sSite As String = hidloc.GetVal.Value Log(sSite) hj.Download(IIf(sSite.EndsWith("/"), sSite.SubString2(0, sSite.Length - 1), sSite) & "/sess") wait for (hj) JobDone(hj As HttpJob) hj.Release I also have placed a breakpoint in the filter request handle but it does not stop there and the same is valid for the custom handler request. I am through with ideas on how to deal with it. Can somebody advise on anything that maybe I have missed?
I tried today for the first time to use a session object in websocket and I keep getting this error: java.lang.RuntimeException: Object should first be initialized (HttpSession). Click to expand... I searched the forum and found the solutions in: jServer v4.0 - Based on Jetty 11 Starting from B4J v9.80 this library is included as an internal library. Old library: https://www.b4x.com/android/forum/threads/141323/#content This is a new version of jServer. It is based on Jetty 11. Previous versions were based on an early version of Jetty 9. There were many improvements in... www.b4x.com and in safari session variables in b4j v4 Hi i have problems with sessions variables with safari after upgrade to version 4. it seems that browser lose values. Chrome and firefox works correctly. In safari i have the accept cookies and data from all sites active. can anyone help me? www.b4x.com I implemented them but I keep getting this error. I even tried a handler which is called at runtime when the websocket is connected (hidloc is a hidden control which gets the window.location; ) with this code (the handler Handle sub is the same as the filter's sub): B4X: Dim hj As HttpJob hj.Initialize("", Me) Dim sSite As String = hidloc.GetVal.Value Log(sSite) hj.Download(IIf(sSite.EndsWith("/"), sSite.SubString2(0, sSite.Length - 1), sSite) & "/sess") wait for (hj) JobDone(hj As HttpJob) hj.Release I also have placed a breakpoint in the filter request handle but it does not stop there and the same is valid for the custom handler request. I am through with ideas on how to deal with it. Can somebody advise on anything that maybe I have missed?
Erel B4X founder Staff member Licensed User Longtime User Oct 28, 2022 #2 I don't see how this code has anything to do with the "session filter". Try to reproduce it in a small project, based on: https://www.b4x.com/android/forum/threads/safari-session-variables-in-b4j-v4.61652/#post-389898 Upvote 0
I don't see how this code has anything to do with the "session filter". Try to reproduce it in a small project, based on: https://www.b4x.com/android/forum/threads/safari-session-variables-in-b4j-v4.61652/#post-389898
hatzisn Expert Licensed User Longtime User Oct 28, 2022 #3 Erel said: I don't see how this code has anything to do with the "session filter". Try to reproduce it in a small project, based on: https://www.b4x.com/android/forum/threads/safari-session-variables-in-b4j-v4.61652/#post-389898 Click to expand... Hi, I used already the code mentioned in the link you posted. I added the filter and your code (and also the srvr.Addfilter.... in main) . I was still getting the "session must be initialized". Your code is executed obviously when the web page tries to get the "b4j_ws.js". Is this right? I added a breakpoint in the filter hande sub and it does not ever get there to stop the execution in debug mode. Then I decided to do this manually I added a handler which is called manually with the httpjob by adding this command in main: B4X: srvr.AddHandler("/sess", "ManualSessionCreator", False) and I used the code I have written in the first post to call this handler. This code mentioned is called in websocket_connected. The handler's code is the following: B4X: Sub Handle(req As ServletRequest, resp As ServletResponse) req.GetSession End Sub I did the same adding a breakpoint in req.GetSession and the same thing happened (no stopping at all). I cannot figure out what is happening... I will try to minify the code and see what is going wrong and let you know. Upvote 0
Erel said: I don't see how this code has anything to do with the "session filter". Try to reproduce it in a small project, based on: https://www.b4x.com/android/forum/threads/safari-session-variables-in-b4j-v4.61652/#post-389898 Click to expand... Hi, I used already the code mentioned in the link you posted. I added the filter and your code (and also the srvr.Addfilter.... in main) . I was still getting the "session must be initialized". Your code is executed obviously when the web page tries to get the "b4j_ws.js". Is this right? I added a breakpoint in the filter hande sub and it does not ever get there to stop the execution in debug mode. Then I decided to do this manually I added a handler which is called manually with the httpjob by adding this command in main: B4X: srvr.AddHandler("/sess", "ManualSessionCreator", False) and I used the code I have written in the first post to call this handler. This code mentioned is called in websocket_connected. The handler's code is the following: B4X: Sub Handle(req As ServletRequest, resp As ServletResponse) req.GetSession End Sub I did the same adding a breakpoint in req.GetSession and the same thing happened (no stopping at all). I cannot figure out what is happening... I will try to minify the code and see what is going wrong and let you know.
Erel B4X founder Staff member Licensed User Longtime User Oct 28, 2022 #4 hatzisn said: Then I decided to do this manually I added a handler which is called manually with the httpjob by adding this command in main: Click to expand... This is completely wrong. Upvote 0
hatzisn said: Then I decided to do this manually I added a handler which is called manually with the httpjob by adding this command in main: Click to expand... This is completely wrong.
hatzisn Expert Licensed User Longtime User Oct 28, 2022 #5 I fixed it. I changed the position of the Port setting. I moved the srvr.Port = xxxxx after the srvr.AddFilter("/b4j_ws.js", "SessionCreator") and just before srvr.Start as I have seen this in WebAppHelloWorld example. It worked. Why does this position matter? Upvote 0
I fixed it. I changed the position of the Port setting. I moved the srvr.Port = xxxxx after the srvr.AddFilter("/b4j_ws.js", "SessionCreator") and just before srvr.Start as I have seen this in WebAppHelloWorld example. It worked. Why does this position matter?
Erel B4X founder Staff member Licensed User Longtime User Oct 30, 2022 #6 hatzisn said: I moved the srvr.Port = xxxxx after the srvr.AddFilter("/b4j_ws.js", "SessionCreator") and just before srvr.Start Click to expand... It makes no difference. Upvote 0
hatzisn said: I moved the srvr.Port = xxxxx after the srvr.AddFilter("/b4j_ws.js", "SessionCreator") and just before srvr.Start Click to expand... It makes no difference.
hatzisn Expert Licensed User Longtime User Oct 31, 2022 #7 Then I suppose B4J feared your reactions and decided to behave itself. Upvote 0