We’re currently randomly experiencing this error:

OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 104

Accompanied also with error 56 from curl.

The majority of uploads “just work”, but randomly a video is stubborn and does not. However after retrying a few times, mostly it works. But we’ve had cases where it doesn’t.

I tried to use twurl to see if I can reproduce it, but I ran into the following trace which could be similar but I can’t say (not a Ruby person):

Traceback (most recent call last):
	27: from /usr/local/bin/twurl:23:in `<main>'
	26: from /usr/local/bin/twurl:23:in `load'
	25: from /var/lib/gems/2.5.0/gems/twurl-0.9.6/bin/twurl:4:in `<top (required)>'
	24: from /var/lib/gems/2.5.0/gems/twurl-0.9.6/lib/twurl/cli.rb:21:in `run'
	23: from /var/lib/gems/2.5.0/gems/twurl-0.9.6/lib/twurl/cli.rb:40:in `dispatch'
	22: from /var/lib/gems/2.5.0/gems/twurl-0.9.6/lib/twurl/abstract_command_controller.rb:7:in `dispatch'
	21: from /var/lib/gems/2.5.0/gems/twurl-0.9.6/lib/twurl/request_controller.rb:15:in `dispatch'
	20: from /var/lib/gems/2.5.0/gems/twurl-0.9.6/lib/twurl/request_controller.rb:19:in `perform_request'
	19: from /var/lib/gems/2.5.0/gems/twurl-0.9.6/lib/twurl/oauth_client.rb:184:in `perform_request_from_options'
	18: from /usr/lib/ruby/2.5.0/net/http.rb:1458:in `request'
	17: from /usr/lib/ruby/2.5.0/net/http.rb:910:in `start'
	16: from /usr/lib/ruby/2.5.0/net/http.rb:1460:in `block in request'
	15: from /usr/lib/ruby/2.5.0/net/http.rb:1467:in `request'
	14: from /usr/lib/ruby/2.5.0/net/http.rb:1494:in `transport_request'
	13: from /usr/lib/ruby/2.5.0/net/http.rb:1494:in `catch'
	12: from /usr/lib/ruby/2.5.0/net/http.rb:1495:in `block in transport_request'
	11: from /usr/lib/ruby/2.5.0/net/http/generic_request.rb:121:in `exec'
	10: from /usr/lib/ruby/2.5.0/net/http/generic_request.rb:188:in `send_request_with_body'
	 9: from /usr/lib/ruby/2.5.0/net/protocol.rb:206:in `write'
	 8: from /usr/lib/ruby/2.5.0/net/protocol.rb:224:in `writing'
	 7: from /usr/lib/ruby/2.5.0/net/protocol.rb:207:in `block in write'
	 6: from /usr/lib/ruby/2.5.0/net/protocol.rb:233:in `write0'
	 5: from /usr/lib/ruby/2.5.0/openssl/buffering.rb:338:in `write'
	 4: from /usr/lib/ruby/2.5.0/openssl/buffering.rb:338:in `inject'
	 3: from /usr/lib/ruby/2.5.0/openssl/buffering.rb:338:in `each'
	 2: from /usr/lib/ruby/2.5.0/openssl/buffering.rb:339:in `block in write'
	 1: from /usr/lib/ruby/2.5.0/openssl/buffering.rb:322:in `do_write'
/usr/lib/ruby/2.5.0/openssl/buffering.rb:322:in `syswrite': Broken pipe (Errno::EPIPE)

Anyway, not to distract too much from our application error…

I could reproduce this on two different system (though both are Ubuntu 18 based).

We’re still investigating but I’m wondering if someone else is seeing this?

I’m getting hundreds of SSL errors with an errno 104 as well. It happens not only a particular endpoint, but on all of them.

It started last week. Before, I had none. My host is OVH (Gravelines).

Edit: I’m using PHP Library TwitterOAuth.

For the initial report I was using tmhOAuth which is like super outdated.

I’ve then whipped up an implementation using Guzzle 7 by hand it’s exactly the same:

GuzzleHttp\Exception\RequestException with message 'cURL error 56: OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 104 (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://upload.twitter.com/1.1/media/upload.json'

On the last system I tested this I also updated all Ubuntu packages to ensure I’ve the latest curl/tls/php libs.

I also noticed the last HTTP request, which then leads to the abort, has the http_code 100 and no response.

Twitter is using multiple DNS records, maybe some servers are faulty in terms of TLS:

$ nslookup upload.twitter.com
Server:		192.168.1.1
Address:	192.168.1.1#53

Non-authoritative answer:
Name:	upload.twitter.com
Address: 104.244.42.75
Name:	upload.twitter.com
Address: 104.244.42.203
Name:	upload.twitter.com
Address: 104.244.42.139
Name:	upload.twitter.com
Address: 104.244.42.11

I can confirm this: the first time this starts on a regular basis is the 2021-05-11:

day	        errors
2021-05-11	10
2021-05-12	11
2021-05-13	12
2021-05-14	17
2021-05-15	3
2021-05-16	9
2021-05-17	20
2021-05-18	30
2021-05-19	26
2021-05-20	4

I forgot to check this: unfortunately I’m not sure I’ve enough data, but for now I only see this with video uploads.

Any update here? Still getting the same error randomly every day since mid-may.

@andypiper Is there any Twitter Staff on the forum working on Twitter networks that could give us a hint? Thanks!

Hello,

I have the same issue with code 104 when i stream with python TwitterAPI.

Traceback (most recent call last):
  File "/home/xxx/anaconda3/envs/ai/lib/python3.7/site-packages/urllib3/response.py", line 437, in _error_catcher
    yield
  File "/home/xxx/anaconda3/envs/ai/lib/python3.7/site-packages/urllib3/response.py", line 519, in read
    data = self._fp.read(amt) if not fp_closed else b""
  File "/home/xxx/anaconda3/envs/ai/lib/python3.7/http/client.py", line 461, in read
    n = self.readinto(b)
  File "/home/xxx/anaconda3/envs/ai/lib/python3.7/http/client.py", line 495, in readinto
    return self._readinto_chunked(b)
  File "/home/xxx/anaconda3/envs/ai/lib/python3.7/http/client.py", line 590, in _readinto_chunked
    chunk_left = self._get_chunk_left()
  File "/home/srg/anaconda3/envs/ai/lib/python3.7/http/client.py", line 558, in _get_chunk_left
    chunk_left = self._read_next_chunk_size()
  File "/home/xxx/anaconda3/envs/ai/lib/python3.7/http/client.py", line 518, in _read_next_chunk_size
    line = self.fp.readline(_MAXLINE + 1)
  File "/home/xxx/anaconda3/envs/ai/lib/python3.7/socket.py", line 589, in readinto
    return self._sock.recv_into(b)
  File "/home/xxx/anaconda3/envs/ai/lib/python3.7/ssl.py", line 1071, in recv_into
    return self.read(nbytes, buffer)
  File "/home/xxx/anaconda3/envs/ai/lib/python3.7/ssl.py", line 929, in read
    return self._sslobj.read(len, buffer)
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/xxx/anaconda3/envs/ai/lib/python3.7/site-packages/TwitterAPI/TwitterAPI.py", line 373, in _iter_stream
    buf += self.stream.read(1)
  File "/home/xxx/anaconda3/envs/ai/lib/python3.7/site-packages/urllib3/response.py", line 541, in read
    raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
  File "/home/xxx/anaconda3/envs/ai/lib/python3.7/contextlib.py", line 130, in __exit__
    self.gen.throw(type, value, traceback)
  File "/home/xxx/anaconda3/envs/ai/lib/python3.7/site-packages/urllib3/response.py", line 455, in _error_catcher
    raise ProtocolError("Connection broken: %r" % e, e)
urllib3.exceptions.ProtocolError: ("Connection broken: ConnectionResetError(104, 'Connection reset by peer')", ConnectionResetError(104, 'Connection reset by peer'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/xxx/repos/2themoon/news-classifier/newsclassifier/websource/api/impl/twitter/v2.py", line 276, in producer_streaming
    for line in stream:
  File "/home/xxx/anaconda3/envs/ai/lib/python3.7/site-packages/TwitterAPI/TwitterAPI.py", line 409, in __iter__
    for item in self._iter_stream():
  File "/home/xxx/anaconda3/envs/ai/lib/python3.7/site-packages/TwitterAPI/TwitterAPI.py", line 399, in _iter_stream
    raise TwitterConnectionError(e)
TwitterAPI.TwitterError.TwitterConnectionError: ("Connection broken: ConnectionResetError(104, 'Connection reset by peer')", ConnectionResetError(104, 'Connection reset by peer'))

Also when i try to stream using curl with bearer token:

$ curl -X GET -H "Authorization: Bearer $BEARER_TOKEN" "https://api.twitter.com/2/tweets/search/stream?tweet.fields=created_at&expansions=author_id&user.fields=created_at"

I receive the tweet but the connection is closed and throws this error with code 104:

{"data":{"id":"1398727721392521216","author_id":"806223543960825857","created_at":"2021-05-29T19:47:30.000Z","text":"a"},"includes":{"users":[{"name":"xxxx","id":"805223543961825857","created_at":"2016-12-06T19:47:26.000Z","username":"xxxx"}]},"matching_rules":[{"id":1398723584600329730,"tag":null}]}
curl: (56) OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 104

Thanks in advance!

Still keeping hundreds of SSL errors every day. No improvement since mid-may.

I honestly have not seen the SSL error again. It disappeared like Thanos snapped his fingers. Maybe something with our error reporting changed and it’s there and we’re not properly seeing it :woman_shrugging:

However, due to this initial problem we’ve implement a retry logic for individual video upload segments and it seems this was smart anyway, as I caught other errors which would otherwise have prevented the upload of the video:

So all I can say: maybe pro-actively retrying helps :crossed_fingers:

cheers