Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uploads break after 30 seconds #29

Open
thekid opened this issue Sep 26, 2022 · 2 comments
Open

Uploads break after 30 seconds #29

thekid opened this issue Sep 26, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@thekid
Copy link
Member

thekid commented Sep 26, 2022

Coming from thekid/dialog#8 (comment), while uploading via curl works, it doesn't when using this library.

Test script

use io\File;
use lang\Throwable;
use util\cmd\Console;
use webservices\rest\{Endpoint, RestUpload};

$api= new Endpoint($argv[2]);
$transfer= new File($argv[1]);
$target= 'target.mp4';

// Test code
Console::writeLine('Upload ', $transfer, ' ', $transfer->size());
$upload= new RestUpload($api, $api
  ->resource('images/{0}', [$target])
  ->request('PUT')
  ->waiting(read: 3600)
);
try {
  foreach (['video' => $transfer] as $kind => $file) {
    $upload->transfer($kind, $file->in(), $target);
  }
  $r= $upload->finish();
  Console::writeLine('-> ', $r);
} catch (Throwable $t) {
  $t->printStackTrace();
}

We also have debug output in webservices.rest.RestUpload::transfer() to show progress!

Results

$ xp upload.script.php huge-file.mp4 https://tests.example.com/
Upload io.File(uri= C:\Tools\Cygwin\home\timmf\devel\huge-file.mp4, mode= rb) 13801052
BEGIN target.mp4 [
  <21:24:18>...............
  <21:24:19>...............
  <21:24:20>..............
  <21:24:21>..........
  <21:24:22>................
  <21:24:23>............
  <21:24:24>..............
  <21:24:25>...............
  <21:24:26>..............
  <21:24:27>...............
  <21:24:28>..............
  <21:24:29>.........
  <21:24:30>....................
  <21:24:31>..............
  <21:24:32>..............
  <21:24:33>.........
  <21:24:34>...............
  <21:24:35>..............
  <21:24:36>...............
  <21:24:37>........
  <21:24:38>....................
  <21:24:39>...............
  <21:24:40>..............
  <21:24:41>...............
  <21:24:42>.............
  <21:24:43>............
  <21:24:44>..............
  <21:24:45>..............
  <21:24:46>...............
  <21:24:47>.............. 
  <21:24:48>......................................................................... (1200 more dots)
]
Exception webservices.rest.RestException (Cannot send request)
  at <main>::fputs() [line 358 of Socket.class.php] fputs(): SSL: Eine bestehende Verbindung wurde softwaregesteuert
durch den Hostcomputer abgebrochen (... 1258 more)
  at <main>::fputs() [line 358 of Socket.class.php] fputs(): SSL operation failed with code 1. OpenSSL Error messages:
error:1409E10F:SSL routines:ssl3_write_bytes:bad length (... 1 more)
  at <main>::fread() [line 314 of Socket.class.php] fread(): SSL: Der Vorgang wurde erfolgreich beendet
  at webservices.rest.Endpoint::finish(webservices.rest.io.Transmission{}) [line 92 of RestUpload.class.php]
  at webservices.rest.RestUpload::finish() [line 23 of upload.script.php]
  at <main>::include((0x11)'upload.script.php') [line 163 of Code.class.php]
  at xp.runtime.Code::run(array[3]) [line 31 of Evaluate.class.php]
  at xp.runtime.Evaluate::main(array[3]) [line 389 of class-main.php]
Caused by Exception lang.FormatException ("" is not a valid HTTP response [-1])
  at <main>::fputs() [line 358 of Socket.class.php] fputs(): SSL: Eine bestehende Verbindung wurde softwaregesteuert
durch den Hostcomputer abgebrochen (... 1258 more)
  at <main>::fputs() [line 358 of Socket.class.php] fputs(): SSL operation failed with code 1. OpenSSL Error messages:
error:1409E10F:SSL routines:ssl3_write_bytes:bad length (... 1 more)
  at <main>::fread() [line 314 of Socket.class.php] fread(): SSL: Der Vorgang wurde erfolgreich beendet
  at peer.http.HttpResponse::readHeader() [line 37 of HttpResponse.class.php]
  at peer.http.HttpResponse::__construct(peer.SocketInputStream{}) [line 125 of SocketHttpTransport.class.php]
  at peer.http.SocketHttpTransport::finish(peer.http.ChunkedHttpOutputStream{}) [line 148 of HttpConnection.class.php]
  at peer.http.HttpConnection::finish(peer.http.ChunkedHttpOutputStream{}) [line 54 of Transmission.class.php]
  ... 6 more

👉 after 30 seconds, things begin failing, fputs() doesn't return false but raises all these 1259 SSL: Eine bestehende Verbindung wurde softwaregesteuert durch den Hostcomputer abgebrochen warnings.

@thekid thekid added the bug Something isn't working label Sep 26, 2022
thekid added a commit to xp-framework/networking that referenced this issue Sep 26, 2022
Fixes thousands of repeated warning messages being raised, see xp-forge/rest-client#29
@thekid
Copy link
Member Author

thekid commented Sep 26, 2022

Cannot reproduce this with dialog running on localhost, even if I slow down the uploads so that they take significantly longer than 30 seconds:

BEGIN target.mp4 [
  <22:01:32>.................
  <22:01:33>..............................
  # ...
  <22:02:25>...............................
]
-> webservices.rest.RestResponse(200 OK)@{
  Date: Mon, 26 Sep 2022 20:01:32 GMT
  Server: XP
  Connection: close
  Content-Type: application/json
  Content-Length: 0
}

@thekid
Copy link
Member Author

thekid commented Sep 26, 2022

If I slow down upload artifically, the timeout doesn't occur after 30 seconds, but later:

BEGIN target.mp4 [
  <22:12:19>..................
  <22:12:20>.............
  # ...
  <22:13:47>............
]
Exception webservices.rest.RestException (Cannot send request)
  at <main>::fputs() [line 358 of Socket.class.php] fputs(): SSL: Eine bestehende Verbindung... (... 834 more)
  at <main>::fputs() [line 358 of Socket.class.php] fputs(): SSL operation failed with code 1. ... (... 1 more)
  at <main>::fread() [line 314 of Socket.class.php] fread(): SSL: Der Vorgang wurde erfolgreich beendet
  at webservices.rest.Endpoint::finish(webservices.rest.io.Transmission{}) [line 93 of RestUpload.class.php]
  at webservices.rest.RestUpload::finish() [line 23 of upload.script.php]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant