B4J Question B4J server and Early EOF error

marcick

Well-Known Member
Licensed User
Longtime User
In one of the handlers of the B4J server, I have sometimes the "Early EOF error".
Which could be the cause and how to avoid it ?
The handler is created with SingleThreadHandler to false, so I thing I should not have problems related to multiple access.

This is the code where the error is generated

B4X:
'Handler class
Sub Class_Globals

End Sub

Public Sub Initialize
    
End Sub

Sub Handle(req As ServletRequest, resp As ServletResponse)
    Dim ClientId As String=req.GetParameter("clientid")               <<< this line
    Dim ClientVersion As String=req.Getparameter("version")

and this is the full error log

B4X:
2018-07-11 09:27:58 App Error 2: (RuntimeIOException) org.eclipse.jetty.io.RuntimeIOException: org.eclipse.jetty.io.EofException: Early EOF
(RuntimeIOException) org.eclipse.jetty.io.RuntimeIOException: org.eclipse.jetty.io.EofException: Early EOF
org.eclipse.jetty.io.RuntimeIOException: org.eclipse.jetty.io.EofException: Early EOF
    at org.eclipse.jetty.server.Request.extractFormParameters(Request.java:552)
    at org.eclipse.jetty.server.Request.extractContentParameters(Request.java:471)
    at org.eclipse.jetty.server.Request.getParameters(Request.java:386)
    at org.eclipse.jetty.server.Request.getParameter(Request.java:1025)
    at anywheresoftware.b4j.object.JServlet$ServletRequestWrapper.GetParameter(JServlet.java:232)
    at jrdc.bmap4aw.devicetoken._handle(devicetoken.java:69)
    at sun.reflect.GeneratedMethodAccessor20.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:90)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:77)
    at anywheresoftware.b4j.object.JServlet$Handle.run(JServlet.java:130)
    at anywheresoftware.b4j.object.JServlet.Handle(JServlet.java:110)
    at anywheresoftware.b4j.object.JServlet.doPost(JServlet.java:80)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
    at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:865)
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:535)
    at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255)
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1595)
    at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255)
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1253)
    at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:203)
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:473)
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1564)
    at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:201)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1155)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:144)
    at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:126)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
    at org.eclipse.jetty.server.Server.handle(Server.java:531)
    at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:352)
    at org.eclipse.jetty.server.HttpChannelOverHttp.earlyEOF(HttpChannelOverHttp.java:238)
    at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:1502)
    at org.eclipse.jetty.server.HttpConnection.parseRequestBuffer(HttpConnection.java:360)
    at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:250)
    at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:281)
    at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:102)
    at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:118)
    at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:333)
    at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310)
    at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:168)
    at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:126)
    at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:366)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:760)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:678)
    at java.lang.Thread.run(Unknown Source)
Caused by: org.eclipse.jetty.io.EofException: Early EOF
    at org.eclipse.jetty.server.HttpInput$3.getError(HttpInput.java:1133)
    at org.eclipse.jetty.server.HttpInput$3.noContent(HttpInput.java:1121)
    at org.eclipse.jetty.server.HttpInput.read(HttpInput.java:313)
    at org.eclipse.jetty.server.HttpInput.read(HttpInput.java:256)
    at org.eclipse.jetty.util.UrlEncoded.decodeUtf8To(UrlEncoded.java:484)
    at org.eclipse.jetty.util.UrlEncoded.decodeTo(UrlEncoded.java:572)
    at org.eclipse.jetty.server.Request.extractFormParameters(Request.java:547)
    ... 46 more
 

DonManfred

Expert
Licensed User
Longtime User
i would check if the parameter is available in the parameters first

Did you try?
 
Upvote 0

marcick

Well-Known Member
Licensed User
Longtime User
I didn't try but it must be, unless the connection broken.
The error appears rarely.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
The handler is created with SingleThreadHandler to false, so I thing I should not have problems related to multiple access.
Not really related however it will also work properly with multiple access and SingleThreadHandler = True (though it is better to set it to False).

My guess is that connection was broken. This will happen from time to time.
 
Upvote 0

marcick

Well-Known Member
Licensed User
Longtime User
I have put a try catch to see if the parameter is available in the parameters as DonManfred suggest. And sometime it isn't.
So I skip the error this way.
Thank you all
 
Upvote 0
Top