com.jcraft.jsch.JSchException: Session.connect: java.io.IOException: End of IO Stream Read - sftp

While connecting SFTP I am getting following error.
com.jcraft.jsch.JSchException: Session.connect: java.io.IOException: End of IO Stream Read
Please guide me,

Actually i think the answer is trivial. You are not able to open a stream i.e. the sftp connexion is not estabmlished sucessfully. Check wit IT team or support if there is firewalls or so and that can see you arriving on the server.

Related

Error occurred while closing file from remote server in MuleSoft

I am trying to read the file from Remote SFTP server using Mule Requestor in MuleSoft version 3.8.5. I can see in the logs connection is getting established with Remote SFTP server but while closing the connection its throwing an error as below :
Error occurred while closing file fileName.dat
java.io.IOException: Pipe closed
I am not sure is it due to file length and connection is getting timed out or anything else.
After Mule requester, Byte-Array to String transformer is there. And exception is thrown there is :
Could not close stream
java.io.IOException: Pipe closed
at java.io.PipedInputStream.read(PipedInputStream.java:307)
at java.io.PipedInputStream.read(PipedInputStream.java:377)
at com.jcraft.jsch.ChannelSftp.fill(ChannelSftp.java:2909)
at com.jcraft.jsch.ChannelSftp.header(ChannelSftp.java:2935)
at com.jcraft.jsch.ChannelSftp.access$500(ChannelSftp.java:36)
at com.jcraft.jsch.ChannelSftp$RequestQueue.cancel(ChannelSftp.java:1262)
at com.jcraft.jsch.ChannelSftp$2.close(ChannelSftp.java:1530)
Any suggestion or help is appreciated.
This seems to occur when the sftp connection is terminated by the sftp server or cut by e.g. a firewall. I was able to recreate the issue at will using the tcpkill (8) command to terminate the sftp connection that Mule runtime holds open.
Using a pooling profile with eviction times seems to work.
<sftp:config name="Upload_CSV_SFTP_Config" doc:name="SFTP Config" doc:id="88bf2e97-86d2-40fc-af79-536ec838f2d2" >
<sftp:connection host="${secure::transfer.sftp.hostname}" port="${secure::transfer.sftp.port}" username="${secure::transfer.sftp.username}" knownHostsFile="${secure::transfer.sftp.known_hosts_file}" identityFile="${secure::transfer.sftp.identity_file}" workingDir="${secure::transfer.sftp.directory}" passphrase="${secure::transfer.sftp.passphrase}">
<reconnection >
<reconnect frequency="30000" />
</reconnection>
<pooling-profile evictionCheckIntervalMillis="60000" initialisationPolicy="INITIALISE_NONE"/>
</sftp:connection>
</sftp:config>
Mule 4 SFTP Config
Before that, I had tried various combinations of the basic reconnection options on the SFTP config and also the options on the SFTP operation itself, but none seemed to help. One 'hack' that I used at first was to put an SFTP List operation with a path of . (current directory) immediately before the SFTP Read or Write operation.

issue apache kafka connection with arduino client

I've a problem when I try to connect my Arduino uno, with the PubSubClient library, like a client to my Apache Kafka server.
When I try to establish a connection, on the server I have this:
[2016-09-07 16:30:59,093] WARN Unexpected error from /192.168.1.104; closing connection (org.apache.kafka.common.network
.Selector)
org.apache.kafka.common.network.InvalidReceiveException: Invalid receive (size = 270204932 larger than 104857600)
at org.apache.kafka.common.network.NetworkReceive.readFromReadableChannel(NetworkReceive.java:91)
at org.apache.kafka.common.network.NetworkReceive.readFrom(NetworkReceive.java:71)
at org.apache.kafka.common.network.KafkaChannel.receive(KafkaChannel.java:154)
at org.apache.kafka.common.network.KafkaChannel.read(KafkaChannel.java:135)
at org.apache.kafka.common.network.Selector.pollSelectionKeys(Selector.java:323)
at org.apache.kafka.common.network.Selector.poll(Selector.java:283)
at kafka.network.Processor.poll(SocketServer.scala:472)
at kafka.network.Processor.run(SocketServer.scala:412)
at java.lang.Thread.run(Thread.java:745)
It seems there is inter-broker communication, due to which broker got a request
more than the default allowed size of 10MB. Kindly do a fresh re-install of kafka cluster and see if it helps.

JSch session.connect() hungs with CoreFTP

I have CoreFTP configured for localhost and the next code:
JSch.setLogger(new MyJschLogger()); //class for console output
Session session = jsch.getSession("user", "localhost", 21);
Properties config = new Properties();
config.put("StrictHostKeyChecking", "no");
session.setConfig(config);
session.setPassword("password");
session.connect();
when program achieves connect(), two messages appear at console output:
INFO: Connecting to localhost port 21
INFO: Connection established
...and nothing more happens. After some minutes, connection is closed by foreign host exception appears.
Why?
Thanks for all!
Port 21 is the normal port for FTP. JSch is only an SSH client, with support for SFTP in the ChannelSFTP class. JSch knows nothing about FTP (and SFTP is unrelated to FTP, other than by name and that it allows similar things).
You need to setup your server to use the SSH protocol (usually on port 22, but you can use any port, as long as you use the same port on the client). See the documentation - I think you have to check the SSH check box.
Also, if your code is nothing more than what you posted, then nothing more than connecting will happen. To transfer files, you will need to open a ChannelSFTP, and issue the right commands (e.g. call one or more of the put/get methods).
I also faced the similar issue:
"ERROR 2016-04-27 15:05:16,489 [CollectionThreadPool-0] com.dell.supportassist.collector.cli.executor.SSHExecutor: com.jcraft.jsch.JSchException: connection is closed by foreign host"
In my case, channel was getting closed randomly. And when we are trying to re-connect the channel then it was not re-connecting and failing.
This was happening due to looping logic while connecting, so I tried to connect the session without channel by calling method connectWithoutOpenChannel instead of connectinternal(). This resolved my issue.

Service not available, closing transmission channel. The server response was: 4.4.2 Timeout while waiting for command

I'm trying to send a message and we sometime get this error :
Service not available, closing transmission channel. The server response was: 4.4.2 Timeout while waiting for command.
Anyone know what to do with this? Because it only happens "sometime" and apperently, for no specific reason.
I saw many article saying :
442 The server started to deliver the message but then the connection was broke (Source : http://www.sorkincomputer.net/SMTP%20errors.htm)
This is typically a server side (the SMTP server you're delivering to) error or a network connectivity error. There isn't anything you can do about it via your code, you would need to get the related IT staff involved to figure out why your connection is getting closed or interrupted.

Sandbox violation on second socket send

I have a Flex client using a Flash binary (TCP) socket for communication with a Java server. I have a localhost (Apache) server providing a crossdomain.xml file which is wide open just while I am testing.
My code successfully loads the policy file on startup.
I then connect the socket to the server without any difficulty and send a message and get a response. All good so far.
However, when I send a second message through the same socket I get a pause of about 12 seconds then a sandbox violation error:
Security Error: Error #2048: Security sandbox violation: file:///C:/apache_root/ttt1/ttt1.swf cannot load data from localhost:45455.
This is the same port and socket through which the first message succeeded.
I tried re-loading the policy file before every send, but I get the same result.
Any idea why this might be happening? I clearly have an open socket at one point. I am flushing the socket after each send and I tried doing that after each read as well, but the same result.
Thanks in advance
EDIT:
If I recreate the socket prior to every call my code works. I am struggling to believe that this is correct, but maybe there is a Socket setting I am missing.
As far as I know if you're doing binary sockets the crossdomain.xml is not loaded via http.
Have you checked your apache's access logs if the crossdomain is even queried?
You might get connection from flash via tcp from flash asking for the file on your java server (not using http. It just sends the string "" or similar). Look out for them. If you don't answer them within 3 seconds (or so) flash throws an sandbox violation.
The first thing you have to do when you want to make a socket connection is to load the policy file. This only has to be done once per load of the SWF.
Security.allowDomain(host);
Security.loadPolicyFile("xmlsocket://"+host+":"+port);
The request will be made on the assigned port(45455 in your case) your server will have to listen on that port for a request "<policy-file-request/>" without the quotes.
When that request is found then you need to return to the client the crossdomain.xml
with node <allow-access-from domain="*" to-ports="*" />
After the cross domain is sent you need to close the socket on the server side
On the client side you need to ignore the domain response as Flex will handle that however at that time you can reconnect to the socket server.
At this time you can do your data send/receive.
I have a feeling the reason it actually worked for you is because you were using the connection for the policy file to transmit your data before it timed out.
I would suggest reading up on the new style of crossdomain policies and also reading up on the protocol you are using for your socket server
I think it depends on the sandbox-policy you used in the compilation process of your swf not on your crossdomain.xml... maybe this docu helps you:Security sandboxes
But I'm not 100% sure
This sort of sounds like a cache problem. Perhaps you're pulling the first socket connection out of cache and the second one gets rejected because it's getting a 200 from the server.
You might want to add localhost to your flash security exceptions list for debugging. that will quiet the sandbox errors until you get your piece to it's production environment.

Resources