java.net.SocketException: Network is unreachable: connect Response data in JMeter - java

I am trying to send HTTP request through HTTP sampler to linux server (Red Hat), in local intranet environment.
I am getting this exception in Response Data
Please guide me.
Regards

It looks like that your JMeter isn't capable for establishing connection. If you can access this site with a browser you're behind a proxy.
There are 2 options on how to record scripts from behind a proxy:
Run JMeter specifying proxy host, port, username and password as follows:
jmeter -H (IP address or hostname of your proxy server) -P (port of your proxy server) -u (username, if required) -a (password, if required)
Example: jmeter -H 10.10.10.1 -P 3128
Use JMeter Extension for Google Chrome. In this case you won't need to care about proxies, certificates, headers, etc. and will be able to record tests to .jmx files right from browser.

First ping the host; you are trying to connect. If ping working try telnet <80> ... It is a network issue.

Related

Spring Boot, using oracle-ldap url through ssh tunnel on local machine

There are 3 machines:
local -> some remote server -> oracle db server (via ldap)
I want to set up datasource connection (in my spring boot app) to the oracle db.
There is no direct connectivity between local machine and the one with oracle db.
So, i'm using the ssh tunnel through remote server:
ssh -L 127.0.0.1:8081:some.ldap.host:389 user#remote.server.host
In application.yml file i'm using further url:
spring:
datasource:
url: jdbc:oracle:thin:#ldap://127.0.0.1:8081//srvcnm,cn=OracleContext,dc=yy,dc=xx,dc=com
And when my app trying to get db connection, im getting the following error:
Caused by: oracle.net.nt.TimeoutInterruptHandler$IOReadTimeoutException: Socket read timed out
at oracle.net.nt.TimeoutSocketChannel.handleInterrupt(TimeoutSocketChannel.java:254)
at oracle.net.nt.TimeoutSocketChannel.connect(TimeoutSocketChannel.java:103)
at oracle.net.nt.TimeoutSocketChannel.<init>(TimeoutSocketChannel.java:77)
at oracle.net.nt.TcpNTAdapter.connect(TcpNTAdapter.java:192)
... 126 common frames omitted
Whenever i'm deploying app on the remote server and enter "direct" url in application.yml the connection is being obtained without any timeouts, and the app works well.
jdbc:oracle:thin:#ldap://some.ldap.host:389//srvcnm,cn=OracleContext,dc=yy,dc=xx,dc=com
Does anyone know how to handle this? How to get connection from local machine?
I may do some thing like this, I am going to create file call ~/.ssh/config then add following
Host remoteserver1
User usermane
Hostname ip or host name
ForwardAgent yes
Host oracleserver
User username
Hostname some.ldap.host
Port 22
# ForwardAgent yes if you need to forward one more instance
LocalForward 8081 some.ldap.host:389
ProxyCommand ssh -q -W %h:%p remoteserver1
What this does is that when I attempt to connect to ssh oracleserver from remoteserver1, it connects to hopper and then proxies the SSH connection to port 22 on overthere (ie: SSH on oracleserver).
now to connect via ssh do following ssh oracleserver , as it will make ssh tunnel between your machine and oracleserver via remoteserver1. along with port forwarding.
The problem was in redirecting source connection request to another machine with oracle db itself (after ldap auth).
So, the request's path looked like:
1.local -> 2.remote server -> 3.ldap server -> 4.oracle db server
There wasn't connectivity between 1st and 4th machine as the tunnel was only between 1th and 3rd one.
So, you if you faced this issue, you may add one more ssh tunnel (First tunnel is for ldap server, second one for oracle db) and enrich your "etc/hosts" with oracle server's routing.
In my case the issue was in access restrictions. The oracle server is filtering sockets somehow and grants access to certain machines.

Fargate: Sending email to private smtp server on port 25

I'm using AWS Fargate as my container platform. My container base image is openjdk:8-alpine and the application is a spring-boot app. I'm attempting to use JavaMailSender to send emails over a vpn tunnel to our internal SMTP server on port 25. This works while testing the container locally, using the same SMTP server.
I've mainly used this guide https://www.baeldung.com/spring-email for the email functionality in my spring boot app.
If I add the following commands to the docker entrypoint I test hostname resolving and telnet connection. The host and dig commands always work. Sometimes telnet works and other times it will timeout, causing a re-deployment of the container. When sending emails I see the same behavior. Some emails will send while others fail due to a timeout connecting to the SMTP server.
## Dockerfile
FROM openjdk:8-alpine
COPY core/target/app.jar /app/app.jar
WORKDIR /app
CMD CMD host $my_smtp_server \
&& dig $my_smtp_server \
&& telnet $my_smtp_server 25 \
&& java -jar $app.jar
EXPOSE 8080 25
## application.properties
# Mail config
#------------
spring.mail.default-encoding=UTF-8
spring.mail.host=$my_smtp_server
spring.mail.port=25
spring.mail.protocol=smtp
spring.mail.properties.mail.smtp.starttls.enable=false
spring.mail.properties.mail.smtp.starttls.required=false
spring.mail.properties.mail.smtp.auth=false
spring.mail.properties.mail.smtp.connectiontimeout=5000
spring.mail.properties.mail.smtp.timeout=5000
spring.mail.properties.mail.smtp.writetimeout=5000
#------------
Emails should send every time I invoke the function in my application.

Haproxy config for bitbucket server

I am using haproxy for port forwarding to Bitbucket server ssh. Here's haproxy config:
frontend sshd
bind *:7999
default_backend ssh
timeout client 1h
backend ssh
mode tcp
server localhost-bitbucket-ssh 127.0.0.1:7999 check port 7999
However if i do:
sudo haproxy -f haproxy.cfg
i am getting the following error:
[ALERT] 305/201411 (4168) : http frontend 'sshd' (haproxy.cfg:38) tries to use incompatible tcp backend 'ssh' (haproxy.cfg:43) as its default backend (see 'mode').
[ALERT] 305/201411 (4168) : Fatal errors found in configuration.
But i was referring to an official atlassian guide: https://confluence.atlassian.com/bitbucketserver/setting-up-ssh-port-forwarding-776640364.html are they wrong?
Also if i start haproxy before bitbucket server, bitbucket server cannot start on port 7999. I am totally confused. I have paid for that software and now i need to figure it out myself how to configure it for more than 2 days...
UPDATE
It was UFW as Thomj mentioned. But for what purposes do i need haproxy? If i can't bind Bitbucket's ssh to 22 port? I don't like to set port number.
The frontend configuration is defaulting to a mode of http which can't use a backend that's configured for tcp. Try adding 'mode tcp' to the frontend:
frontend sshd
bind *:7999
default_backend ssh
timeout client 1h
mode tcp

SSLHandshakeException when trying to connect to host

I am using the weblogicserver and I have enabled HTTPS connector.
I have a standalone Java program which connects to a site say, "xyz.com" and fetches me json over HTTPS. But when I try to run the same program on the server, it throws SSLHandshakeException.
Post the stacktrace...Have you added the certificate into weblogic trust store "cacerts"?
What are your java_options settings?If not set then try something similar to below
JAVA_OPTIONS="-Dweblogic.security.SSL.trustedCAKeyStore=/weblogic92/server/lib/c‌​acerts ${JAVA_OPTIONS}"

How to SSH tunnel and connect to a database using IntelliJ and JDBC?

I'm having issues connecting to a database hosted on a server using IntelliJ and JDBC. With the command line, the command:
ssh username#server -L 11100:ct1:28017 -N
creates a tunnel successfully and the command:
psql db_name -h localhost -p 11100 db_username
connects to the database fine and allows me to use it. How would this be translated correctly into the IntelliJ Data Sources and the SSH tunnel tools?
At the moment, for the SSH tunnel settings I have:
Proxy Host: server
Port: 22
Proxy user: username
For the general tab I have:
host: localhost
port: 28017
database: db_name
user: db_username
The connection returns successfully after testing the connection. Inside my program I have:
Connection connection = DriverManager.getConnection("jdbc:postgresql://localhost:28017/db_name", user, password);
The URL parameter is the one generated by IntelliJ. This however gives me an error "Connection to localhost:28017 refused."
Any ideas on what I am doing wrong?
Here's my setup via intellij if anyone is looking for simple solution without external libraries.
Open Database view (View -> Tool Windows -> Database).
Add new DataSource (right-click, New -> Data Source ->
Postgres/Mysql). In host, use 127.0.0.1 (not localhost, sometimes
localhost is not properly resolved).
Fill in rest of the fields as configured on your remote host.
Now click on SSH/SSL tab and configure ssl tunnel:
Do you connect to SSH server from a java client like SSHJ (https://github.com/hierynomus/sshj) ?
The URL on your DriverManager seems wrong: try port 11100 instead.
If the error is Exhausted available authentication methods ❶, make sure that the passphrase ❷ is provided if required. This is easy to forget because the passphrase is often supplied automatically by the OS keyring manager, which makes it seem like the key does not have one.
The credentials in ❸ are for Postgres. These will not work with peer authentication. In my case, I needed this in pg_hba.conf:
hostnossl all rdahl 127.0.0.1/32 md5
The proxy host and user in ❹ are for the ssh server as seen from the client.
The docs from JetBrains are odd and left me in doubt if this is just using an existing SSH tunnel, or if it creates one. It creates one.
The Test Connection buttons in the two dialogs both trigger the same test.

Categories

Resources