Http: SocketException after long time POST

Created on 22 Mar 2019  路  3Comments  路  Source: dart-lang/http

If i make a long time post with MultipartRequest class i get a SocketException after 70 seconds
Setting timeouts have no effect.

Exception:
SocketException: OS Error: Software caused connection abort, errno = 103, address = 192.168.1.1, port = 54136

Codesnippet:

```
final Uri url = ......
MultipartRequest request = new MultipartRequest("POST", url);
Uint8List data = .......

Map headers = {
"Content-Type": "multipart/form-data",
"Expect": "100-continue",
"Accept": "/"
};

final MultipartFile multipartFile = MultipartFile.fromBytes("firmware", data);
request.headers.addAll(headers);
request.files.add(multipartFile);

try {
return await request.send();
} catch (error) {
print(error.toString());
}

**The POST with curl is successful.**

$ curl -v -F filenmae=@filexyz http://192.168.1.1/upload.cgi

  • Trying 192.168.1.1...
  • TCP_NODELAY set
  • Connected to 192.168.1.1 (192.168.1.1) port 80 (#0)

POST /upload.cgi HTTP/1.1
Host: 192.168.1.1
User-Agent: curl/7.61.1
Accept: /
Content-Length: 7602006
Content-Type: multipart/form-data; boundary=------------------------db58954d11f68cd8
Expect: 100-continue

< HTTP/1.1 100 Continue
< Server: xyz/0.0.8
< Content-Length: 0
< Connection: keep-alive

  • Done waiting for 100-continue
    < HTTP/1.1 102 Processing
    < Server: xyz/0.0.8
    < Content-Length: 0
    < Connection: keep-alive
    < HTTP/1.1 201 Created
    < Server: xyz/0.0.8
    < Content-Length: 0
    < Connection: close
  • Closing connection 0
    ```

Most helpful comment

We have the same issue when sending a simple post request that contains a JSON (no multipart like in the issue above)
Is there any documentation on the error codes? In this case 103.

All 3 comments

We have the same issue when sending a simple post request that contains a JSON (no multipart like in the issue above)
Is there any documentation on the error codes? In this case 103.

Same here

I get the same exception in my flutter app (SocketException: OS Error: Software caused connection abort, errno = 103).
I have an app with a long-lasting websocket connection. When the app was in the background for a long time (>>60min), I can't get any network connection going once the app is resumd. Neither the mentioned websocket connection, nor a new websocket connection, nor a simple http GET to google.com.
The app-integrated Sentry-SDK can make network calls though (logging the mentioned exception).
Any ideas or workarounds?

Happens on iOS 13, Android 9 and 10 and Windows. Tested with stable, dev and master channels.

Was this page helpful?
0 / 5 - 0 ratings