> On Nov 9, 2022, at 6:47 AM, 'Kenton Varda' via Cap'n Proto 
> <capnproto@googlegroups.com> wrote:
> 
> Have you tested whether your server is able to accept concurrent connections 
> normally? E.g. if you open a connection with telnet or something without 
> sending any bytes, leave that open, and then try to use your server, does it 
> work?

Thanks! That was indeed the problem. The telnet test showed my server would 
accept multiple connections at once, but would only authenticate one of them at 
a time, so a client that didn’t send the right handshake would block others. 

(I’m using custom code, largely copied from rpc.c++ and tls.c++, but 
substituting the SecretHandshake protocol (from Scuttlebutt) for TLS. When I 
adapted TlsConnectionReceiver::acceptLoop, I got things in the wrong order, so 
the tail-recursion back to acceptLoop didn’t occur until the secure handshake 
finished.)

I’ve fixed it now. Next question: if I want to run client connections on 
multiple threads, I presume that after the accept-and-handshake finishes, I 
would create a new thread with an event loop, then use an Executor to pass the 
AsyncIoStream to it, and then do the magic RPC setup on that thread. On 
disconnect I’d either exit the thread or return it to a pool for reuse. Most of 
this seems like boilerplate … are there any working examples I could steal from?

(Why would I want multiple threads when CapnP is async? Because my actual RPC 
methods do SQLite queries, which are blocking and sometimes slow, and I’d 
rather not create async wrappers for my entire complicated database API.)

—Jens

-- 
You received this message because you are subscribed to the Google Groups 
"Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to capnproto+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/capnproto/8A947B79-0997-4DEB-9A9A-3EF7B0ACB024%40mooseyard.com.

Reply via email to