B4J Question Jetty setting maxIdleTime

Status
Not open for further replies.

alwaysbusy

Expert
Licensed User
Longtime User
I'm experiencing Timeouts in on the server side streaming audio files. Although these messages appear in the log, the audio file keeps playing.

B4X:
java.util.concurrent.TimeoutException: Idle timeout expired: 30001/30000 ms
   at org.eclipse.jetty.io.IdleTimeout.checkIdleTimeout(IdleTimeout.java:166)
   at org.eclipse.jetty.io.IdleTimeout$1.run(IdleTimeout.java:50)
   at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
   at java.util.concurrent.FutureTask.run(FutureTask.java:266)
   at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
   at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
   at java.lang.Thread.run(Thread.java:745)
2016-03-10 17:18:35.259:WARN:oejs.HttpChannel:qtp23170705-13: //localhost:51042/demo/Audio/04%20Steal.mp3
java.io.IOException: java.util.concurrent.TimeoutException: Idle timeout expired: 30001/30000 ms
   at org.eclipse.jetty.util.SharedBlockingCallback$Blocker.block(SharedBlockingCallback.java:226)
   at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:164)
   at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:436)
   at org.eclipse.jetty.util.IO.copy(IO.java:163)
   at org.eclipse.jetty.util.resource.Resource.writeTo(Resource.java:682)
   at org.eclipse.jetty.servlet.DefaultServlet.sendData(DefaultServlet.java:995)
   at org.eclipse.jetty.servlet.DefaultServlet.doGet(DefaultServlet.java:520)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
   at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:821)
   at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:583)
   at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:224)
   at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1158)
   at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:511)
   at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
   at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1090)
   at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
   at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:109)
   at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:119)
   at org.eclipse.jetty.server.Server.handle(Server.java:517)
   at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:308)
   at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:242)
   at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:261)
   at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95)
   at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:75)
   at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceAndRun(ExecuteProduceConsume.java:213)
   at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:147)
   at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:654)
   at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:572)
   at java.lang.Thread.run(Thread.java:745)

Searching the net, I should be able to extend this timeout, e.g maxIdleTime=500000. (it is 30000 by default).

I tried:

B4X:
srvr.SetStaticFilesOptions(CreateMap("cacheControl": "max-age=604800,public","gzip":True,"dirAllowed":False, "maxIdleTime":"500000"))

But I do not think this is the right place to set this param (it is ignored).
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
You can use this code:
B4X:
srvr.Start
Dim jo As JavaObject = srvr
Dim connectors() As Object = jo.GetFieldJO("server").RunMethod("getConnectors", Null)
Dim timeout As Long = 50000
For Each c As JavaObject In connectors
   c.RunMethod("setIdleTimeout", Array(timeout))
Next
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
I solved the issue on the browsers side

can you please explain how?
i am streaming mp4 movies on my server and every time i load a video i get after 30sec this error message. everything keeps working fine but i still get this error. can you please tell me how you solved it?

thanx
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
Upvote 0

bridge1

Member
You can use this code:
B4X:
srvr.Start
Dim jo As JavaObject = srvr
Dim connectors() As Object = jo.GetFieldJO("server").RunMethod("getConnectors", Null)
Dim timeout As Long = 50000
For Each c As JavaObject In connectors
   c.RunMethod("setIdleTimeout", Array(timeout))
Next

GetIdleTimeout:
Sub Process_Globals
    Private serverHTTP As HttpServer
    Private mPort As Int = 4444
End Sub

Sub Service_Create
    serverHTTP.Initialize("serverHTTP")   
    serverHTTP.Start(mPort)
End Sub

Public Sub GetIdleTimeout As Int()

    Dim joServerHttp As JavaObject = serverHTTP   
    Dim joSrv As JavaObject = joServerHttp.GetFieldJO("[B]server[/B]")   
End Sub

Using the HttpServer library, trying to retrieve the server object, reports the following error.
java.lang.RuntimeException: Field: server not found in: anywheresoftware.b4a.objects.HttpServer

Note that in debug, for object joServerHttp, server object is displayed.

What can we do?

Thank you.
 
Upvote 0
Status
Not open for further replies.
Top