JSCH to connect to remote server to download files is giving error failed to send channel request - spring-boot

I am using jsch to download filed from a remote server to local server. Below is the code segment to download the files:
Channel channel = session.openChannel("sftp");
channel.connect(channelTimeout);
channelSftp.connect(10000);
channelSftp.cd(remoteDir);
for (Object entry : channelSftp.ls(remoteDir)) {
if (entry instanceof ChannelSftp.LsEntry) {
String filename = ((ChannelSftp.LsEntry) entry).getFilename();
if (!filename.equals(".") && !filename.equals("..")) {
channelSftp.get(filename, localDir + filename);
}
}
}
but each time I run the code i am getting the below error:
20:44:09.205 [main] ERROR - Error download file
com.jcraft.jsch.JSchException: failed to send channel request
at com.jcraft.jsch.Request.write(Request.java:65)
at com.jcraft.jsch.RequestSftp.request(RequestSftp.java:47)
at com.jcraft.jsch.ChannelSftp.start(ChannelSftp.java:237)
at com.jcraft.jsch.Channel.connect(Channel.java:152)
The weird part is if I run the application in debug mode, I am not getting any error and the application completes successfully.
Can anyone help why this error is occurring only while running and not while debugging.
note - I am using spring boot application.

Related

File upload stuck on large files with Spring Web on Windows

I have a JHipster application providing a REST endpoint for uploading files.
This code works without any problem in a Docker container on a Linux machine but seems to be stuck in the same Docker container running on Windows.
#PostMapping("/datafiles")
#Timed
public ResponseEntity<DataFileDTO> createDataFile(#Valid #RequestParam("file") MultipartFile data,
#Valid #RequestHeader("workspaceId") Long workspaceId, RedirectAttributes redirectAttributes)
throws URISyntaxException, IOException {
log.debug("REST request to save a data content");
DataFileDTO result = dataFileService.createFromData(data, workspaceId);
return ResponseEntity.created(new URI("/api/datafiles/" + result.getId()))
.headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())).body(result);
}
This code works for 12Mb video file but when I try to upload a file which is 70Mb, no debug log appears and the server is blocked until I get a timeout from undertow
Jan 29 15:26:46 StorageService StorageService-dockerstorage_storageservice-app_1.network:8081: ERROR - io.undertow.request : UT005023: Exception handling request to /api/datafiles
java.io.IOException: UT000128: Remote peer closed connection before all data could be read
at io.undertow.conduits.FixedLengthStreamSourceConduit.exitRead(FixedLengthStreamSourceConduit.java:338)
at io.undertow.conduits.FixedLengthStreamSourceConduit.read(FixedLengthStreamSourceConduit.java:255)
at org.xnio.conduits.ConduitStreamSourceChannel.read(ConduitStreamSourceChannel.java:127)
at io.undertow.channels.DetachableStreamSourceChannel.read(DetachableStreamSourceChannel.java:209)
at io.undertow.server.HttpServerExchange$ReadDispatchChannel.read(HttpServerExchange.java:2343)
at org.xnio.channels.Channels.readBlocking(Channels.java:294)
at io.undertow.servlet.spec.ServletInputStreamImpl.readIntoBuffer(ServletInputStreamImpl.java:192)
at io.undertow.servlet.spec.ServletInputStreamImpl.read(ServletInputStreamImpl.java:168)
at io.undertow.server.handlers.form.MultiPartParserDefinition$MultiPartUploadHandler.parseBlocking(MultiPartParserDefinition.java:223)
at io.undertow.servlet.spec.HttpServletRequestImpl.parseFormData(HttpServletRequestImpl.java:792)
... 43 common frames omitted
Changing the timeout just leaves the server waiting but nothing happens on my part of code.
Is there something specific to Windows in this case ?
I finally found that the problem is not on the JHipster side but is related to the configuration of the NGinx Docker container running the frontend.
It seems that the default configuration is different in this case.

Bug CleverBeagle Pup 2.0 Meteor GraphQL deployment on Heroku

1) In the first time, when I deployed the origin code to heroku server with git clone https://github.com/cleverbeagle/pup
The launching application didn't work.
I managed to correct this with to copy the content of 'settings-development.json' file and paste in Heroku => myProject => Setttings => Reveal Config Vars => Key : METEOR_SETTINGS and Value : I pasted here the content.
thanks to :
- https://github.com/cleverbeagle/pup/issues/9
- https://github.com/cleverbeagle/pup/issues/197
So, now, the app is showing on server.
2) On Chrome console, I have this error :
50d72c91808ef7fba57f920b67d152d2d57698eb.js?meteor_js_resource=true:9 WebSocket connection to 'ws://localhost:4001/graphql' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
so I changed this in METEOR_SETTINGS
"graphQL": {
"httpUri": "http://localhost:3000/graphql",
"wsUri": "ws://localhost:4001/graphql"
},
to
"graphQL": {
"httpUri": "https://myproject.herokuapp.com:3000/graphql",
"wsUri": "wss://myproject.herokuapp.com:4001/graphql"
},
Note without https and wss, the app is not showing
3) Now on Chrome Console, I have :
this warning :
50d72c91808ef7fba57f920b67d152d2d57698eb.js?meteor_js_resource=true:9 WebSocket connection to 'wss://myproject.herokuapp.com:4001/graphql' failed: WebSocket is closed before the connection is established.
and after several warning above, I have this error :
50d72c91808ef7fba57f920b67d152d2d57698eb.js?meteor_js_resource=true:9 WebSocket connection to 'wss://myproject.herokuapp.com:4001/graphql' failed: WebSocket opening handshake timed out
By using the origin source code from Pup, I can signup on server but I cannot create a new document.
Any help, please ?
Thank you
EDIT 15 JAN 2019
**4) I remove Port like this : **
"httpUri": "https://myproject.herokuapp.com/graphql",
"wsUri": "wss://myproject.herokuapp.com/graphql"
Now, I can create New document on https://myproject.herokuapp.com/documents
but I still have this warning :
fe6fa1ac83e19aa2513ac3f97293600e8dc99e8e.js?meteor_js_resource=true:9
WebSocket connection to 'wss://myproject.herokuapp.com/graphql'
failed: WebSocket is closed before the connection is established.
and this error :
WebSocket connection to 'wss://myproject.herokuapp.com/graphql'
failed: Error during WebSocket handshake: Unexpected response code:
503
any idea ?
Thanks

Apache Directory Authentication Failed?

I am trying to connect the OpenLdap through Apache Directory Studio and its working upto Network Parameter and check Network Parameter working fine.
But Next step i am trying to Authentication and its failed with below message.
The authentication failed
- The response queue has been emptied, no response was found. org.apache.directory.api.ldap.model.exception.LdapException: The
response queue has been emptied, no response was found. at
org.apache.directory.ldap.client.api.LdapNetworkConnection.bind(LdapNetworkConnection.java:1327)
at
org.apache.directory.studio.connection.core.io.api.DirectoryApiConnectionWrapper$2.run(DirectoryApiConnectionWrapper.java:368)
at
org.apache.directory.studio.connection.core.io.api.DirectoryApiConnectionWrapper.runAndMonitor(DirectoryApiConnectionWrapper.java:1269)
at
org.apache.directory.studio.connection.core.io.api.DirectoryApiConnectionWrapper.doBind(DirectoryApiConnectionWrapper.java:460)
at
org.apache.directory.studio.connection.core.io.api.DirectoryApiConnectionWrapper.bind(DirectoryApiConnectionWrapper.java:306)
at
org.apache.directory.studio.connection.core.jobs.CheckBindRunnable.run(CheckBindRunnable.java:79)
at
org.apache.directory.studio.connection.ui.RunnableContextRunner$1.run(RunnableContextRunner.java:127)
at
org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:119)
Caused by:
org.apache.directory.api.ldap.model.exception.LdapException: TimeOut
occurred at
org.apache.directory.ldap.client.api.LdapNetworkConnection.bind(LdapNetworkConnection.java:1305)
... 7 more
The response queue has been emptied, no response was found.

System.Net.Http.HttpRequestException exception will running th xamarin UI Test on Physical Device

I have created a simple Xamarin.Forms(Portable) project and included UI Test project in it. But when i am trying to run the test in physical device it giving me below mentioned exception.
Test Name: AppLaunches
Test Outcome: Failed
Result Message:
SetUp : System.Net.Http.HttpRequestException : An error occurred while sending the request.
----> System.Net.WebException : The underlying connection was closed: The connection was closed unexpectedly.
Result StandardOutput: Full log file: C:\Users\Admin\AppData\Local\Temp\uitest\log-2016-10-22_11-04-53-698.txt
Skipping IDE integration as important properties are configured. To force IDE integration, add .PreferIdeSettings() to ConfigureApp.
Android test running Xamarin.UITest version: 2.0.0.1534
Initializing Android app on device ZX1D63GCCL with installed app: co.veloxcore.UITestSample2
Signing apk with Xamarin keystore.
Skipping installation: Already installed.
Here is the link to my project: XamarinUITest
Log File : Error Log
Are you using using ModernHttpClient?
Also you can use Polly if you want to handle network exceptions.
For example:
conferences = await Policy
.Handle<WebException>()
.WaitAndRetry
(
retryCount:5,
sleepDurationProvider: retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt))
)
.ExecuteAsync(async () => await getConferencesTask);
Also AsyncErrorHandler is great tool to handle async exceptions

Mule File Transport to Read files from Windows SMB Share

I am trying to write a file to a Windows SMB share.
The Mule File Transport documentation says that I should be able to access a Windows Location as follows:
file:////192.168.0.1/temp/
Here is my mule flow: I would like to know if there is a resolution for this. Thanks!
<file:outbound-endpoint responseTimeout="10000" doc:name="File" address="file:////<IPAddress>/ShareName/" outputPattern="hello.xml"/>
I get the following error:
Message : Streaming failed. Could not get output stream. Failed to route event via endpoint: DefaultOutboundEndpoint{endpointUri=file:////<IPAddress>/ShareName/, connector=FileConnector
{
name=connector.file.mule.default
lifecycle=start
this=2b1f76e1
numberOfConcurrentTransactedReceivers=4
createMultipleTransactedReceivers=true
connected=true
supportedProtocols=[file]
serviceOverrides=<none>
}
, name='endpoint.file.<IPAddress>.ShareName', mep=ONE_WAY, properties= {outputPattern=hello.xml}, transactionConfig=Transaction{factory=null, action=INDIFFERENT, timeout=0}, deleteUnacceptedMessages=false, initialState=started, responseTimeout=10000, endpointEncoding=UTF-8, disableTransportTransformer=false}. Message payload is of type: String
Code : MULE_ERROR-42999
--------------------------------------------------------------------------------
Exception stack is:
1. No such file or directory (java.io.IOException)
java.io.UnixFileSystem:-2 (null)
2. Streaming failed. Could not get output stream. Failed to route event via endpoint: DefaultOutboundEndpoint{endpointUri=file:////<IPAddress>/ShareName/, connector=FileConnector
{
name=connector.file.mule.default
lifecycle=start
this=2b1f76e1
numberOfConcurrentTransactedReceivers=4
createMultipleTransactedReceivers=true
connected=true
supportedProtocols=[file]
serviceOverrides=<none>
}
, name='endpoint.file.<IPAddress>.ShareName', mep=ONE_WAY, properties={outputPattern=hello.xml}, transactionConfig=Transaction{factory=null, action=INDIFFERENT, timeout=0}, deleteUnacceptedMessages=false, initialState=started, responseTimeout=10000, endpointEncoding=UTF-8, disableTransportTransformer=false}. Message payload is of type: String (org.mule.api.transport.DispatchException)
org.mule.transport.file.FileConnector:569 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transport/DispatchException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
java.io.IOException: No such file or directory
at java.io.UnixFileSystem.createFileExclusively(Native Method)
at java.io.File.createNewFile(File.java:883)
at org.mule.util.FileUtils.createFile(FileUtils.java:93)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
Using the file transport to access a UNC path works when Mule is executing on a Windows operating system.
Since it seems that you are in a Unix machine you will have to use the CIFS/SMB protocol.
There is a community supported module called mule-transport-cifs that can help you with this.
After adding this module to your project you should be able to use it by chaning the file outbound-enpdoint to something like this.
<smb:outbound-endpoint host="<IPAddress>" user="username" password="secret" path="/ShareName" outputPattern="hello.xml"/>

Resources