Android Question Running php scripts too fast

yge

Member
Licensed User
When I go from one activity to another, 2 or 3 jobs are usually called (post string method via php scripts). Everything works fine! When I try to switch activities faster, jobs are processing faster in lesser time, and after 3rd or 4th switch, I get this Response Error:

B4X:
ResponseError. Reason: java.io.IOException: unexpected end of stream on okhttp3.Address@875051fe, Response:

It seems like a jobs overload to me. After this error happens, I have to wait around minute or so, otherwise that ResponseError appears on every job called (instead of JobDone). I guess they need their time to be released.

Is there any solution or this is a normal situation?
 

DonManfred

Expert
Licensed User
Hiding your code does not help us help you.

The job should always released in jobdone sub.
 
Upvote 0

yge

Member
Licensed User
@OliverA I saw that one. I didn't manage to find a solution since the log I posted is all I get. No idea how OkHttpUtils2 reacts to this, like does it resend the request in 60 seconds or maybe there is another method...

@DonManfred Everything is correct. Jobs work fine. Job is always released in JobDone sub.This is an issue that appears only when there are a lot of jobs requested in a very short time. By the way, what If I want to finish the activity before Job.Release? Is it a mistake, or the Job will be released automatically?
 
Upvote 0

KMatle

Expert
Licensed User
Use ONE service to do all that stuff and always ask yourself "why do I need to start more than ONE job to do a complete task?". Usually it is a design error if you answer that question with "yes".

Golden rule: ONE request = ONE job = complete task

Imagine you have 100.000 users working with your app -> server down.

Exceptions:

- you do a login first
- you have to call different servers at one time (which is rare)
 
Upvote 0

yge

Member
Licensed User
Thank you for your answers guys.

@Erel I made some tests and code modifications - it is the server capacity that is causing that error. I bought a cheap godaddy server for testing, so that is why this is happening. Despite claiming that the server can deal with up to 100 entry processes at the same moment, it freezes at around 20-30 or so. I will have to buy a new one, more powerful and faster.

@KMatle I do not use services for jobs. I dim the job, then initialize it, then poststring (and getrequest.timeout if needed) in an imageview click. I guess I should change it via service? About the question, that is a mistake. Since my php knowledge is not that good, I made more scripts with less code and that is why it is starting more than one job. I will have to unite the scripts to a maximum level. I got it, "less jobs - longer scripts" is better than "more jobs - shorter scripts". The server is one, and all I use is one database with several tables. For having 100k + users working at the same time I will need a dedicated server for sure. I expect about 100-200 users max at the same time. Any recommendations for a good and not that expensive server?
 
Upvote 0
Top