B4J Question Httputils2 call from websocket event

b4auser1

Well-Known Member
Licensed User
Longtime User
I have strange problem:

I have in my web app 2 places where send http request to server.
In one place it works reliably in both debug and release modes.

2017-08-08 21:11:05.871:INFO::HttpUtils2: SubmitJob
2017-08-08 21:11:06.091:INFO::HttpUtils2: hc_ResponseSuccess1)
2017-08-08 21:11:06.095:INFO::HttpUtils2: Response_StreamFinish1)
2017-08-08 21:11:06.095:INFO::HttpUtils2: CompleteJob1)
2017-08-08 21:11:06.095:INFO::HttpJob: Complete)
...

But in other place hc_ResponseSuccess is raised only if app start in debug mode.

If app starts in release mode I see in logs only:
2017-08-08 21:11:16.307:INFO::HttpUtils2: SubmitJob

I tried before resumable subs and had similar problems. Which is why I decided to try usual callbacka and still hc_ResponseSuccess doesn't come.
 

b4auser1

Well-Known Member
Licensed User
Longtime User
It seems I found what I did wrong: I placed my class wrapper with HttpsUtils2 class into session.

After I declared my class wrapper with HttpsUtils2 class as member variable of server handler. (Now I have two server handler classes and accordingly two wrappers/httputils2) problems disappeared and I hope will not come back.
 
Upvote 0

b4auser1

Well-Known Member
Licensed User
Longtime User
Original:
B4X:
Sub hc_ResponseSuccess (Response As OkHttpResponse, TaskId As Int)
    Response.GetAsynchronously("response", File.OpenOutput(TempDir, TaskId), False), _
        True, TaskId)
End Sub

I add to each file special prefix to avoid naming conflict between HttpUtils2 instances working in concurrent server threads.
B4X:
Sub hc_ResponseSuccess (Response As OkHttpResponse, a_iTaskId As Int)
    Response.GetAsynchronously("response", File.OpenOutput(TaskResponseContentDirName, TaskResponseContentFileName(a_iTaskId), False), _
        True, a_iTaskId)
End Sub
 
Upvote 0
Top