B4J Question Server Handler Error

ilan

Expert
Licensed User
Longtime User
hi

i am getting errors in the logs when making a request to a server handler.

the problem is that it does not happen always but what i noticed is that it happens always when the server is running for the first time.
making the request again does not fire those logs:


what could be the reason for that?
i am calling the handler from an email url.
 

OliverA

Expert
Licensed User
Longtime User
You may have posted in wrong forum. Does it happen in release mode also (looks like you are running the server in debug mode)
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
Upvote 0

ilan

Expert
Licensed User
Longtime User
You may have posted in wrong forum. Does it happen in release mode also (looks like you are running the server in debug mode)

yes, it is happening also in release mode.
sometimes i also get this error:

 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
If it only happens during start up of the server, it could be a timing issue where request are coming in, but the server is not 100% ready and connections are closed either on client side or server side. Also, such errors can now and then occur during operations due to sporadic network connection failures. The only time to worry about them is if a pattern can be established that certain request cause such failures repeatedly.
 
Upvote 0

ilan

Expert
Licensed User
Longtime User

i can reproduce this error.
every time i restart the server and connect to the Server handler by clicking on a link that directs me to that page i get this error.

this is the relevant code:

B4X:
'Handler class
Sub Class_Globals
   
End Sub

Public Sub Initialize
   
End Sub

Sub Handle(req As ServletRequest, resp As ServletResponse)
    Try
        Dim senderUser As String = req.GetParameter("user")
        Dim senderKey As String = req.GetParameter("key")
        Dim userresetkey As String
        userresetkey = Main.sql1.ExecQuerySingleResult2("SELECT resetpasskey FROM users WHERE username = ?", Array As String(senderUser))
               
        Dim bc As BCrypt
        If bc.CheckPW(senderKey & Main.enckey,userresetkey) Then
            resp.AddCookie(js_code.addCookie("user",bc.HashPW(senderUser),-1,True))
            resp.AddCookie(js_code.addCookie("key",senderKey,-1,True))
            resp.SendRedirect("/rp")
        Else
            resp.AddCookie(js_code.addCookie("user","",0,True)) 'reset cookie
            resp.AddCookie(js_code.addCookie("key","",0,True)) 'reset cookie
            resp.SendError(500, LastException.Message)
        End If
    Catch
        resp.SendError(500, LastException.Message)
        Log(LastException)
    End Try
End Sub

/rp will redirect to a websocket class.
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
/rp will redirect to a websocket class.
I'm pretty sure you need to redirect to a HTML page that incorporates the b4j_ws.js file and the HTML page then connects to the /rp websocket module.
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
First, thank Oliver for helping

I'm pretty sure you need to redirect to a HTML page that incorporates the b4j_ws.js file and the HTML page then connects to the /rp websocket module.

so it does not work like this. i am not connecting to the WebSocket module. rp is the path that is basically a folder that contains some style.css/js and the relevant index.html file. so when the index.html file is loaded the connection is happing AFTER the page was loaded so I am calling an HTML page by directing to /rp

thanx
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…