[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Working on keepalive messages while waiting for local connection



On 11.04.2018 17:31, Andreas Schneider wrote:
> On Wednesday, 11 April 2018 16:27:16 CEST g4-lisz@xxxxxxxxxxxx wrote:
>> Hello all
>>
>> I realized that SSH servers with the keep-alive option enabled first
>> send the keep-alive _global_ request as long as nothing had connected to
>> the local TCP socket:
>>
>> $> ssh -v -N xxx@yyy -L 8088:testcom.com:80
>>
>>     debug1: client_input_global_request: rtype keepalive@xxxxxxxxxxx
>> want_reply 1
>>
>> After connecting to localhost:8088, these requests are sent over the
>> channel:
>>
>>     debug1: client_input_channel_req: channel 2 rtype
>> keepalive@xxxxxxxxxxx reply 1
>>
>> From this I conclude that the channel should not be opened before there
>> is a waiting connection on the local TCP socket.
>> But how do I tell libssh to work on the global request as long as there
>> is no open channel?
>>
>> Maybe I have to use ssh_get_fd() and the use select() also on this
>> socket while waiting for the local incoming connections? And then use
>> ssh_set_fd_toread()?
>>
>> I would appreciate a lot if someone could show me some sample code.
> I think that ssh_event_dopoll() will handle it and call the appropriate 
> callback. Don't use ssh_select()
>
> In master we have the new connector API which is easier to use, see
> https://git.libssh.org/projects/libssh.git/tree/examples/ssh_client.c
>
Thanks, I think that's the issue: The main event polling is not called
why my code waits for a connection. But how do I get the event to which
are attached the default handlers of libssh?

I also looked at the sample code which uses the event API for polling on
the channel. But this would not solve my issue with global keep-alive
requests. They are sent while no channel exists. IMHO it's an issue with
handling messages in the main loop while no channels are open.

Best regards,
Till


Archive administrator: postmaster@lists.cynapses.org