Page 1 of 1
					
				writing data over channel to server problem
				Posted: Wed  05 Nov 2008 21:14
				by snorkel
				I have a server and client setup and running.
the client has a sshclient and channel component on it, both connect fine,
When I do this on the client:
command_chan.WriteString('test'+#13#10);
The server gets the string ok, but then..
The server raises this error:
"Format of server version is invalid"
Any idea what I am doing wrong?
			 
			
					
				
				Posted: Thu  06 Nov 2008 12:21
				by Dimon
				Please, give a more detailed description of your application. Where SSH channel is connected?
It is possible that the error is arised by the end server and not SSH server.
			 
			
					
				
				Posted: Thu  06 Nov 2008 17:45
				by snorkel
				Dimon wrote:Please, give a more detailed description of your application. Where SSH channel is connected?
It is possible that the error is arised by the end server and not SSH server.
the channel is connected to a securebridge ssh server I setup.
On the server I have the ondatafromclient event set to grab any strings sent from the client and it gets the string, then raises that error.
If I send the client version string(command_chan.WriteString('SSH-2.0-Devart-1.0'+#13#10); instead it does not raise the error, but what's thoe point if I can only send a version string.  It's checking every string sent to see if it's a version string and compares it to the version of the server. 
The error on the server is being raised in: 
procedure TProtocolNegotiationHandler.VerifyVersion(const Vers: string); 
Whatever I send to the server over the channel in direct mode gets funnelled through that procedure and raises a error if the string is not SSH-2.0-Devart-1.0
You should not have to send the version string each time you write data to a connected channel.
This is with the latest Version on D2007 by the way, it also occured with the last version.
Here is a example client and server that demos the problem:
http://www.milwaukeesoft.com/example.zip
run the server (ignore the buttons), then run the client and push the button to write a string to the server.  Server will display the string in a messagebox and then raises that error.
 
			
					
				
				Posted: Mon  10 Nov 2008 15:28
				by snorkel
				Anyone have any idea on this?  is it a bug, or am I just doing something wrong?
Thanks,
Snorkel
			 
			
					
				
				Posted: Thu  13 Nov 2008 13:37
				by Dimon
				The problem is that you create command_chan which tries to connect to SSH server as SSH client. 
To create channel only for data exchanging with SSH server you should set Direct to True in the TScSSHServer.BeforeChannelConnect event handler.
			 
			
					
				
				Posted: Fri  14 Nov 2008 18:12
				by snorkel
				Dimon wrote:The problem is that you create command_chan which tries to connect to SSH server as SSH client. 
To create channel only for data exchanging with SSH server you should set Direct to True in the TScSSHServer.BeforeChannelConnect event handler.
ah, I didn't know that.  
so how do i tell which channel is which in that event?
You should do a little demo on how to use the direct mode.
Thanks,
Snorkel
 
			
					
				
				Posted: Fri  14 Nov 2008 18:20
				by snorkel
				snorkel wrote:Dimon wrote:The problem is that you create command_chan which tries to connect to SSH server as SSH client. 
To create channel only for data exchanging with SSH server you should set Direct to True in the TScSSHServer.BeforeChannelConnect event handler.
 
I added this to the event, which I think should work:
direct:= channelinfo.Direct;
but I still get that error about the version.
 
			
					
				
				Posted: Mon  17 Nov 2008 08:59
				by Dimon
				The ChannelInfo.Direct property is not connected with the TScSSHChannel.Direct property and it is connnected only with server settings. Therefore it can be set only in the TScSSHServer.BeforeChannelConnect event handler. You can set it to True checking the DestPort property, like this:
Code: Select all
if ChannelInfo.DestPort = (Sender as TScSSHServer).Port then
  Direct := True;
 
			
					
				
				Posted: Mon  04 Oct 2010 23:11
				by sbrvar
				Dimon wrote:The ChannelInfo.Direct property is not connected with the TScSSHChannel.Direct property and it is connnected only with server settings. Therefore it can be set only in the TScSSHServer.BeforeChannelConnect event handler. You can set it to True checking the DestPort property, like this:
Code: Select all
if ChannelInfo.DestPort = (Sender as TScSSHServer).Port then
  Direct := True;
 
Isn't (Sender as TScSSHServer).Port always 22? How can the destination port of the channel be the same port?
What I'm trying to do is the following:
- I have log server running behind the firewall, listening to port 514
- opened SSH tunnel and all working ok for accessing SQL DB via SDAC
- I'd now like to send log message to log server to port 514 through SSH tunnel
Port forwarding doesn't seem to work in this case, so I assume I have to do something with "Direct" but really can't seem to reach the log server 
 
Any ideas?
Kind regards,
Sabina
 
			
					
				
				Posted: Tue  05 Oct 2010 12:11
				by Dimon
				Setting the ChannelInfo.Direct property to True means that the information received from the SSH client is not passed ahead automatically. In this case the input information must be handled in a handler of the OnDataFromClient event. In this case the channel destination port is used for channel identification, and it doesn't mean that SSH server will connect to itself.
In your case the better way is to use local port forwarding. Please give a more detailed description of the problem that arises in this case.