Ok I figured out how to set the TcpNoDelay option but it did not have any
effect. I am running it with a spring configuration like this:

        <bean id="keyprovider"
class="org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider">
                <constructor-arg value="/tmp/hostkey.ser"/>
        </bean>

        <bean id="userauth" class="MyUserAuth"/>
        <bean id="command" class="MyCommandFactory"/>
        <bean id="socketconfig"
class="org.apache.mina.transport.socket.DefaultSocketSessionConfig">
                <property name="keepAlive" value="true"/>
                <property name="reuseAddress" value="true"/>
                <property name="tcpNoDelay" value="true"/>
        </bean>

        <bean id="sshserver" class="org.apache.sshd.SshServer"
factory-method="setUpDefaultServer" init-method="start"
destroy-method="stop">
                <property name="port" value="2200"/>
                <property name="keyPairProvider" ref="keyprovider"/>
                <property name="passwordAuthenticator" ref="userauth"/>
                <property name="commandFactory" ref="command"/>
                <property name="sessionConfig" ref="socketconfig"/>
        </bean>

Regards

To recap, the problem is that output is not flushed even on explicit calls
to OutputStream.flush() in my command implementation.

Baldur

On Mon, Apr 18, 2011 at 8:56 PM, Baldur Norddahl
<[email protected]>wrote:

> I can not find a way to actually access the underlying socket to do that.
> From the org.apache.sshd.server.Command interface I got a plain
> java.io.OutputStream. This can be cast to
> org.apache.sshd.common.channel.ChannelOutputStream but that will not give me
> any more access to the underlying socket.
>
> Regards,
>
> Baldur
>
>
> On Mon, Apr 18, 2011 at 6:19 PM, Bobby Powers <[email protected]> wrote:
>
>> It sounds like a Nagle problem.  Try setting the NODELAY sockopt.  I'm not
>> familiar with that part of the code, but you need to call
>> setTcpNoDelay(true) on the socket that you're talking over.  Is that
>> enough
>> to get you looking in the right direction?
>>
>> yours,
>> Bobby
>>
>> On Mon, Apr 18, 2011 at 6:53 AM, Baldur Norddahl
>> <[email protected]>wrote:
>>
>> > Hello,
>> >
>> > I created a simple ssh server based on sshd 0.5.0. I am attempting to
>> > integrate with jGit, so I created a simple CommandFactory. Everything is
>> > fine, except no output is send to the client until timeout is reached.
>> When
>> > timeout occurs I get all the git output and socket closes.
>> >
>> > To attempt to remedy this I wrapped my output streams in a class that
>> > flushes after every write. But with no luck, I still get no output. The
>> log
>> > files show that output is being written and flushes being called.
>> >
>> > Anyone have an idea why output is not flushed and what I can do about
>> it?
>> >
>> > Thanks,
>> >
>> > Baldur
>> >
>> > // silly flush helper class that does not help the problem
>> > private class FlushOutputStream extends OutputStream {
>> >     private OutputStream out;
>> >     public FlushOutputStream(OutputStream arg) {
>> >     out = arg;
>> >     }
>> >     @Override
>> >     public void close() throws IOException {
>> >     out.close();
>> >     }
>> >     @Override
>> >     public void flush() throws IOException {
>> >     out.flush();
>> >     }
>> >     @Override
>> >     public void write(byte[] b) throws IOException {
>> >     System.out.println("write: "+new String(b));
>> >     out.write(b);
>> >     out.flush();
>> >     System.out.println("flush");
>> >     }
>> >     @Override
>> >     public void write(byte[] b, int off, int len) throws IOException {
>> >     System.out.println("write: "+new String(b,off,len));
>> >     out.write(b,off,len);
>> >     out.flush();
>> >     System.out.println("flush");
>> >     }
>> > @Override
>> > public void write(int arg0) throws IOException {
>> >     System.out.println("write: "+new String(new byte[] {(byte)arg0}));
>> > out.write(arg0);
>> > out.flush();
>> >     System.out.println("flush");
>> > }
>> >
>> > }
>> >
>>
>
>

Reply via email to