[paramiko] strange behaviour : need help.

Robey Pointer robey at lag.net
Fri Oct 13 11:17:22 PDT 2006


On 3 Oct 2006, at 12:21, jd_jedi at users.sourceforge.net wrote:

> Hi
>    I have written a transport that uses paramiko to create ssh  
> tunnel to remote host and connect to the XMLRPC server on that  
> machine. Basically HTTP requests are tunneled in to remote server  
> and xml response is received back.
>
> I have a transport and I open a channel and return it as socket for  
> XMLRPC proxy to use. For each request a new channel gets created.
>
>       self.sock =  PHelper.open_channel(self.ssh_transport, "direct- 
> tcpip",
>                                         ("localhost",self.port),  #  
> server port
>                                          
> ("localhost",self.localport)) # constant 2000
>
>
> This works great. But every few requests, transport reads the http  
> header part , but then can not read the body.
>
> I started debugging.. put print statements.. enable logs.. etc. I  
> am quite certain that the server is sending the body and the data  
> (through print statements). On the client side, the channel seems  
> to be closed.. (so I thought! ah, this is is.. channel getting  
> closed prematurely.. or something like that.) Enabled paramiko log  
> and saw something that I do not understand.
>
> One can read from ChannelFile even if the channel is closed ? (or  
> there is some buffering.. going on ?)
>
> I will send the log in a separate emais. One for which everything  
> works. And another for which the body is not read.

Nothing in the logs looks unusual.  It is possible to read from a  
channel after you close it, if there was still data buffered,  
although this is more of an accident than intentional. :)

 From the logs, it looks like you're closing the channel explicitly,  
before you receive the response.  In that case, you'll end up in a  
race, hoping the response is sent by the server before it sees your  
"close" request.  You should wait to close the channel after the data  
is read.

If that doesn't help, you can try "set_hexdump(True)" on the  
Transport to see the actual SSH messages go back and forth.

robey




More information about the paramiko mailing list