samedi 15 septembre 2018

Ruby OpenSSL::SSL::SSLSocket hangs for 5 minutes after second gets or eof command

I'm trying to get data from a TCP (SSL) server.

I can successfully make a connection, send a command and read the result (or at least one line of it).

This is my code:

[1] pry(main)> tcp_client = TCPSocket.new("devel1.xxxx", 1234)
=> #<TCPSocket:fd 19>
[2] pry(main)> ssl_client = OpenSSL::SSL::SSLSocket.new(tcp_client)
=> #<OpenSSL::SSL::SSLSocket:0x007fd108a46240 @context=#<OpenSSL::SSL::SSLContext:0x007fd108a46218>, @eof=false, @io=#<TCPSocket:fd 19>, @rbuffer="", @sync=true>
[3] pry(main)> ssl_client.connect
=> #<OpenSSL::SSL::SSLSocket:0x007fd108a46240 @context=#<OpenSSL::SSL::SSLContext:0x007fd108a46218>, @eof=false, @io=#<TCPSocket:fd 19>, @rbuffer="", @sync=true>
[4] pry(main)> ssl_client.puts("{'msg': 'connect', 'projectID':'e4b8de7e-d020-4b80-b60f-f2baa08eeac7', 'username': 's', 'password': 's1234'}")
=> nil
[5] pry(main)> ssl_client.eof?
=> false
[6] pry(main)> ssl_client.gets
=> "{\"msg\":\"connected\",\"connectionid\":100,\"version\":\"2.3.5\"}\r\n"
[7] pry(main)> pp Time.now
=> 2018-09-16 00:00:19 +0200
[8] pry(main)> ssl_client.eof?
[9] pry(main)> pp Time.now
=> 2018-09-16 00:05:19 +0200

After command 6 (which does return data), any command like eof? or gets takes 5 minutes time to respond. What can be causing this?

Aucun commentaire:

Enregistrer un commentaire