[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[Libevent-users] client HTTPS with evhttp



Hi all,

I've been writing a HTTPS client using evhttp in libevent-2.0.16, but I
am running into a roadblock.  I've gone through the last few months of
this list, but I don't see anything exactly about what I am running
into.  I'm hoping you can set me straight.

For context, I'm writing a XMPP (jabber) client that communicates over
Bidirectional-streams Over Synchronous HTTP (BOSH).  The client
establishes a connection to the HTTPS server and makes a request.  The
server doesn't respond until it has something to send, or 30 seconds,
whichever comes first.  At this point the client will make another "long
poll" request to the server.  If the client needs to send more
information and the server is currently tying up the first request, it
makes a second connection.  This second connection may go unused for
long periods of time in between requests, so the underlying socket may
time out.  This usually isn't a problem, since evhttp will spin up
another TCP connection as necessary when a new request is made.

We call evhttp_connection_base_bufferevent_new(), passing the
bufferevent returned from bufferevent_openssl_socket_new() to turn the
HTTP connection into a HTTPS connection.

The problem I'm running into is that when the underlying socket times
out and later a new socket is created, the existing bufferevent is
layered on top of the new TCP connection.  This fails to trigger a new
SSL handshake, leaving the client unable to communicate with the server
on that connection.  Am I using the API incorrectly?  From tracing
through the code a bit, it seems things would work if
evhttp_connection_base_bufferevent_new() took a callback that creates a
bufferevent instead of the bufferevent itself, calling it whenever a new
TCP connection is created, but is there another way to accomplish this
with the existing API?

My team took a look at libevhtp before starting our implementation, but it didn't quite meet our needs. We have an implementation of SSL that we also use for our non-BOSH XMPP connections that we can reuse with the evhttp API but not with the libevhtp API, and we wanted to keep a single implementation of SSL. Also, libevhtp does not look like it will mesh well with non-openssl backends, and our product runs with a variety of crypto backends, depending on the target system.

Thanks,
Myk
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.