b4j posting file using httpUtils erroring

mc73

Well-Known Member
Licensed User
Longtime User
This is not a question for b4j actually. The code I have worked great until 2 weeks ago. In fact it still works when I try to upload very small files.
I'm using httpUtils, to postFile to my server (which is not maintained by me).
If I send a, say 5kb file, everything runs ok.
If I send a file of 800kb, I get this:

INFO: I/O exception (java.net.SocketException) caught when processing request: Software caused connection abort: socket write error

Again, everything worked great until two weeks ago, I've made no changes at the client's side, nor at the server's. So I strongly suspect it's aabaco's team that made changes. The reason of this post is to advice me how to explain to them the problem, if of course there is something more that is needed to be explained.

Thank you.
 

mc73

Well-Known Member
Licensed User
Longtime User
Thank you, Erel.

I haven't got a reply from the company yet, however here's an interesting notice I've just made. The same file is sent without a problem using httputils with android! The only difference is that with android i'm using okHttpUtils. Perhaps, I should give it a try with b4j as well?
 

mc73

Well-Known Member
Licensed User
Longtime User
The post method has no limit at the b4x side but on the server you can set the maximum:

https://www.dokuwiki.org/faq:uploadsize

I've done uploads of 5 MB without any problems. Maybe the hoster does not want large files to be uploaded.
Unfortunately this doesn't seem to be the case, since, as I've written above, the same file is successfully uploaded from the android version of my app. Strange...
 

mc73

Well-Known Member
Licensed User
Longtime User
Sure.

B4J (problem above 100kb):
B4X:
Dim myj As HttpJob
myj.Initialize("uploaddb",Me)
myj.PostFile(myPHPScript,File.DirApp,filename)
myj.Username="username"
myj.Password ="userpass"


B4A (no problem):
B4X:
Dim ajob As HttpJob
ajob.Initialize ("uploaddb",Me)
ajob.Username ="username"
ajob.Password ="userpass"
ajob.PostFile(myPHPScript,File.DirDefaultExternal ,filename)

As I've already mentioned, everything worked as expected some days ago and no change in source was done.
 

moster67

Expert
Licensed User
Longtime User
Any chance you can upload the files in chunks (size of a bit less than 100Kb)?
(as a temporary solution until you find out the problem)
 

mc73

Well-Known Member
Licensed User
Longtime User
Sure. In fact I've already made a change in order to send a zip instead of the original. This solves the problem, for now.
However, it is very strange that two identical sources, behave differently, starting some days ago. And no answer from the company yet.
By the way, testing scripts at my own server (locally) there is no problem at all. So probably it's their configuration. But how on earth, android has no problem and windows has?!
 

moster67

Expert
Licensed User
Longtime User
Did you recently upgrade to the latest B4J-version? If you did, try to get hold of a previous version and try it. Who knows, maybe something was changed in the supporting libraries?
 

mc73

Well-Known Member
Licensed User
Longtime User
Did you recently upgrade to the latest B4J-version? If you did, try to get hold of a previous version and try it. Who knows, maybe something was changed in the supporting libraries?
(Un)fortunately, I've checked older compiles, no difference. However, I remember upgrading to 1.8+ jre (runtime of course), so I'll try downgrading and see if something's really changed. Thank you!
 

DonManfred

Expert
Licensed User
Longtime User
B4J (problem above 100kb):
B4A (no problem):
Have you tried to set username and password in the same order?
Your B4A and B4J codes are different

B4X:
Dim myj As HttpJob
myj.Initialize("uploaddb",Me)
myj.PostFile(myPHPScript,File.DirApp,filename)
myj.Username="username"
myj.Password ="userpass"

->

B4X:
Dim myj As HttpJob
myj.Initialize("uploaddb",Me)
myj.Username="username"
myj.Password ="userpass"
myj.PostFile(myPHPScript,File.DirApp,filename)
 

mc73

Well-Known Member
Licensed User
Longtime User
Thank you Don. Actually I did this too, though I thought it'd make no difference. And indeed it didn't (the process is started afterwards).
I have another step: to setup this project in a PC with older java version. Somehow it seems that the whole thing started after updating to 101.
 

mc73

Well-Known Member
Licensed User
Longtime User
Reverted to 8.66, uninstalled avg and some other things, no differene. @Erel, is there a chance I can try out the 4.20 version, just in case? Cause the hoster insists that there is nothing to fix at their side.
 

KMatle

Expert
Licensed User
Longtime User
For sure it is NOT a B4J or Java problem.

1. Can you post your php script? (maybe the problem is here)
2. I could upload it to my server and we could give it a try
3. Do you have a test environment? (like I'm using XAMPP to test my creations)
 

mc73

Well-Known Member
Licensed User
Longtime User
For sure it is NOT a B4J or Java problem.

1. Can you post your php script? (maybe the problem is here)
2. I could upload it to my server and we could give it a try
3. Do you have a test environment? (like I'm using XAMPP to test my creations)

PHP script:
B4X:
$FileName = $_GET['FileName'];

  if (!$FileName)
  $FileName = "FileName";

  if (strstr($FileName,"php"))
  return;

  $PostData = file_get_contents("php://input");

  $File = fopen("./clients/" . $FileName,"wb");

  fwrite($File, $PostData);
  fclose($File);

  echo "success";

As I've said already, it used to work great until around 20 of August. Since then, android version of the app still works great, but the b4j version not for a 500kb+ file.
In my own localhost I have no problem at all, upload works perfect!
I'm really stuck because no changes were done at my source code, php and b4j.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…