ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:75774] Errno::EAGAIN thrown by OpenSSL::SSL::SSLSocket#connect_nonblock
@ 2016-05-30 16:18 Mohamed Hafez
  2016-05-30 16:36 ` [ruby-core:75775] " Mohamed Hafez
  0 siblings, 1 reply; 4+ messages in thread
From: Mohamed Hafez @ 2016-05-30 16:18 UTC (permalink / raw
  To: ruby-core


[-- Attachment #1.1: Type: text/plain, Size: 985 bytes --]

Hi all, every now and then in my production server, I'm
getting Errno::EAGAIN errors thrown by by
OpenSSL::SSL::SSLSocket#connect_nonblock from at
https://github.com/ruby/ruby/blob/trunk/lib/net/http.rb#L938

I'm using JRuby, so initially I assumed it was just a JRuby implementation
bug and that MRI's  OpenSSL::SSL::SSLSocket#connect_nonblock must
handle Errno::EAGAIN internally, but now that I think about it, the only
way to handle Errno::EAGAIN is to wait for a bit and then retry, and
connect_nonblock isn't supposed to block so how would it do that....

Since this only happens once in a while in production, I don't actually
have a way of seeing if MRI Ruby will also throw this error, but I can't
see how it wouldn't if connect_nonblock can't block for a while before
retrying, but let me know if I'm wrong. If I am correct, could I submit a
pull request to catch Errno::EAGAIN at
https://github.com/ruby/ruby/blob/trunk/lib/net/http.rb#L938 and then retry?

Thanks!
Mohamed

[-- Attachment #1.2: Type: text/html, Size: 1281 bytes --]

[-- Attachment #2: Type: text/plain, Size: 138 bytes --]


Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ruby-core:75775] Re: Errno::EAGAIN thrown by OpenSSL::SSL::SSLSocket#connect_nonblock
  2016-05-30 16:18 [ruby-core:75774] Errno::EAGAIN thrown by OpenSSL::SSL::SSLSocket#connect_nonblock Mohamed Hafez
@ 2016-05-30 16:36 ` Mohamed Hafez
  2016-05-30 19:50   ` [ruby-core:75776] " Eric Wong
  0 siblings, 1 reply; 4+ messages in thread
From: Mohamed Hafez @ 2016-05-30 16:36 UTC (permalink / raw
  To: ruby-core


[-- Attachment #1.1: Type: text/plain, Size: 1295 bytes --]

Or does MRI's  OpenSSL::SSL::SSLSocket#connect_nonblock just return
:wait_writable
in this case, since from my understanding this error gets thrown when the
tcp write buffer is full?

On Mon, May 30, 2016 at 9:18 AM, Mohamed Hafez <mohamed.m.m.hafez@gmail.com>
wrote:

> Hi all, every now and then in my production server, I'm
> getting Errno::EAGAIN errors thrown by by
> OpenSSL::SSL::SSLSocket#connect_nonblock from at
> https://github.com/ruby/ruby/blob/trunk/lib/net/http.rb#L938
>
> I'm using JRuby, so initially I assumed it was just a JRuby implementation
> bug and that MRI's  OpenSSL::SSL::SSLSocket#connect_nonblock must
> handle Errno::EAGAIN internally, but now that I think about it, the only
> way to handle Errno::EAGAIN is to wait for a bit and then retry, and
> connect_nonblock isn't supposed to block so how would it do that....
>
> Since this only happens once in a while in production, I don't actually
> have a way of seeing if MRI Ruby will also throw this error, but I can't
> see how it wouldn't if connect_nonblock can't block for a while before
> retrying, but let me know if I'm wrong. If I am correct, could I submit a
> pull request to catch Errno::EAGAIN at
> https://github.com/ruby/ruby/blob/trunk/lib/net/http.rb#L938 and then
> retry?
>
> Thanks!
> Mohamed
>

[-- Attachment #1.2: Type: text/html, Size: 2227 bytes --]

[-- Attachment #2: Type: text/plain, Size: 138 bytes --]


Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ruby-core:75776] Re: Errno::EAGAIN thrown by OpenSSL::SSL::SSLSocket#connect_nonblock
  2016-05-30 16:36 ` [ruby-core:75775] " Mohamed Hafez
@ 2016-05-30 19:50   ` Eric Wong
  2016-05-30 20:14     ` [ruby-core:75778] " Mohamed Hafez
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Wong @ 2016-05-30 19:50 UTC (permalink / raw
  To: ruby-core

Mohamed Hafez <mohamed.m.m.hafez@gmail.com> wrote:
> On Mon, May 30, 2016 at 9:18 AM, Mohamed Hafez <mohamed.m.m.hafez@gmail.com>
> wrote:
> 
> > Hi all, every now and then in my production server, I'm
> > getting Errno::EAGAIN errors thrown by by
> > OpenSSL::SSL::SSLSocket#connect_nonblock from at
> > https://github.com/ruby/ruby/blob/trunk/lib/net/http.rb#L938
> >
> > I'm using JRuby, so initially I assumed it was just a JRuby implementation
> > bug and that MRI's  OpenSSL::SSL::SSLSocket#connect_nonblock must
> > handle Errno::EAGAIN internally, but now that I think about it, the only
> > way to handle Errno::EAGAIN is to wait for a bit and then retry, and
> > connect_nonblock isn't supposed to block so how would it do that....
>
> Or does MRI's  OpenSSL::SSL::SSLSocket#connect_nonblock just return
> :wait_writable
> in this case, since from my understanding this error gets thrown when the
> tcp write buffer is full?

(top-posting corrected)

Yes, connect_nonblock(exception: false) should not raise for
EAGAIN or Wait*, it should return :wait_* symbol

JRuby needs to implement `exception: false' support which was
added in MRI 2.3

Sorry I could not add that to rubyspec, rubyspec requires
using a proprietary messaging system/workflow to contribute.

> > Since this only happens once in a while in production, I don't actually
> > have a way of seeing if MRI Ruby will also throw this error, but I can't
> > see how it wouldn't if connect_nonblock can't block for a while before
> > retrying, but let me know if I'm wrong. If I am correct, could I submit a
> > pull request to catch Errno::EAGAIN at
> > https://github.com/ruby/ruby/blob/trunk/lib/net/http.rb#L938 and then
> > retry?

No, this should be fixed in other Ruby implementations for 2.3
compatibility.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ruby-core:75778] Re: Errno::EAGAIN thrown by OpenSSL::SSL::SSLSocket#connect_nonblock
  2016-05-30 19:50   ` [ruby-core:75776] " Eric Wong
@ 2016-05-30 20:14     ` Mohamed Hafez
  0 siblings, 0 replies; 4+ messages in thread
From: Mohamed Hafez @ 2016-05-30 20:14 UTC (permalink / raw
  To: Ruby developers


[-- Attachment #1.1: Type: text/plain, Size: 2211 bytes --]

Great, thanks Eric I've posted an issue with JRuby and am digging into its
code to see if I can spot the error myself

On Mon, May 30, 2016 at 12:50 PM, Eric Wong <normalperson@yhbt.net> wrote:

> Mohamed Hafez <mohamed.m.m.hafez@gmail.com> wrote:
> > On Mon, May 30, 2016 at 9:18 AM, Mohamed Hafez <
> mohamed.m.m.hafez@gmail.com>
> > wrote:
> >
> > > Hi all, every now and then in my production server, I'm
> > > getting Errno::EAGAIN errors thrown by by
> > > OpenSSL::SSL::SSLSocket#connect_nonblock from at
> > > https://github.com/ruby/ruby/blob/trunk/lib/net/http.rb#L938
> > >
> > > I'm using JRuby, so initially I assumed it was just a JRuby
> implementation
> > > bug and that MRI's  OpenSSL::SSL::SSLSocket#connect_nonblock must
> > > handle Errno::EAGAIN internally, but now that I think about it, the
> only
> > > way to handle Errno::EAGAIN is to wait for a bit and then retry, and
> > > connect_nonblock isn't supposed to block so how would it do that....
> >
> > Or does MRI's  OpenSSL::SSL::SSLSocket#connect_nonblock just return
> > :wait_writable
> > in this case, since from my understanding this error gets thrown when the
> > tcp write buffer is full?
>
> (top-posting corrected)
>
> Yes, connect_nonblock(exception: false) should not raise for
> EAGAIN or Wait*, it should return :wait_* symbol
>
> JRuby needs to implement `exception: false' support which was
> added in MRI 2.3
>
> Sorry I could not add that to rubyspec, rubyspec requires
> using a proprietary messaging system/workflow to contribute.
>
> > > Since this only happens once in a while in production, I don't actually
> > > have a way of seeing if MRI Ruby will also throw this error, but I
> can't
> > > see how it wouldn't if connect_nonblock can't block for a while before
> > > retrying, but let me know if I'm wrong. If I am correct, could I
> submit a
> > > pull request to catch Errno::EAGAIN at
> > > https://github.com/ruby/ruby/blob/trunk/lib/net/http.rb#L938 and then
> > > retry?
>
> No, this should be fixed in other Ruby implementations for 2.3
> compatibility.
>
> Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>
>

[-- Attachment #1.2: Type: text/html, Size: 3352 bytes --]

[-- Attachment #2: Type: text/plain, Size: 138 bytes --]


Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-05-30 19:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-30 16:18 [ruby-core:75774] Errno::EAGAIN thrown by OpenSSL::SSL::SSLSocket#connect_nonblock Mohamed Hafez
2016-05-30 16:36 ` [ruby-core:75775] " Mohamed Hafez
2016-05-30 19:50   ` [ruby-core:75776] " Eric Wong
2016-05-30 20:14     ` [ruby-core:75778] " Mohamed Hafez

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).