HttpClientException : Request Failure - java

Whenever I run my application, I'm getting the connection request failure exception. The application tries to hit the URL and end up with connection failure.
I have tried the same on Postman. It is giving me 200: OK.
I have the proxy and port as well. How to use it in our spring boot application. Whenever the application runs it should take the respective proxy and port.
I'm attaching here the logs:
creating event for user 0852 for campaign source TEST at stage INITIAL_LANDING
creating event for user 0852 for campaign source TEST at stage CLICK_DEMO
2019-07-19 15:15:39.680 INFO 49560 --- [nio-9898-exec-8] o.a.http.impl.client.DefaultHttpClient : I/O exception (java.net.SocketException) caught when connecting to {s}->https://pi-collector-dev.tr-corporate-nonprod.aws-int.thomsonreuters.com:443: Connection reset
2019-07-19 15:15:39.683 INFO 49560 --- [nio-9898-exec-8] o.a.http.impl.client.DefaultHttpClient : Retrying connect to {s}->https://pi-collector-dev.tr-corporate-nonprod.aws-int.thomsonreuters.com:443
2019-07-19 15:15:49.302 INFO 49560 --- [nio-9898-exec-8] o.a.http.impl.client.DefaultHttpClient : I/O exception (java.net.SocketException) caught when connecting to {s}->https://pi-collector-dev.tr-corporate-nonprod.aws-int.thomsonreuters.com:443: Connection reset
2019-07-19 15:15:49.304 INFO 49560 --- [nio-9898-exec-8] o.a.http.impl.client.DefaultHttpClient : Retrying connect to {s}->https://pi-collector-dev.tr-corporate-nonprod.aws-int.thomsonreuters.com:443
2019-07-19 15:15:58.904 INFO 49560 --- [nio-9898-exec-8] o.a.http.impl.client.DefaultHttpClient : I/O exception (java.net.SocketException) caught when connecting to {s}->https://pi-collector-dev.tr-corporate-nonprod.aws-int.thomsonreuters.com:443: Connection reset
2019-07-19 15:15:58.906 INFO 49560 --- [nio-9898-exec-8] o.a.http.impl.client.DefaultHttpClient : Retrying connect to {s}->https://pi-collector-dev.tr-corporate-nonprod.aws-int.thomsonreuters.com:443
2019-07-19 15:16:08.665 ERROR 49560 --- [nio-9898-exec-8] c.t.providers.persistent.InMemoryQueue : Failed to push events to destination.

Related

How to Shutdown Spring's STOMP Server (SimpleBrokerMessage) programmatically?

I've developed a Spring application that uses STOMP Server, and I would like to shutdown the STOMP server programmatically.
I've tried to shutdown the application using the following code:
SpringApplication.exit(context, new ExitCodeGenerator() {
#Override
public int getExitCode() {
return 0;
}
});
However, the code produces the following error:
...
WARN 15444 --- [ main] o.a.c.loader.WebappClassLoaderBase : The web application [ROOT] appears to have started a thread named [MessageBroker-4] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.base/jdk.internal.misc.Unsafe.park(Native Method)
...
To avoid the error, my plan is to shutdown the STOMP server first and then execute the
SpringApplication.exit( ... )
So, my question is how to shutdown the STOMP server programmatically?
Probably, the code should produce output like this one:
2023-01-13 20:28:05.869 INFO 4380 --- [ionShutdownHook] o.s.m.s.b.SimpleBrokerMessageHandler : Stopping...
2023-01-13 20:28:05.870 INFO 4380 --- [ionShutdownHook] o.s.m.s.b.SimpleBrokerMessageHandler : BrokerAvailabilityEvent[available=false, SimpleBrokerMessageHandler [org.springframework.messaging.simp.broker.DefaultSubscriptionRegistry#5d68db92]]
2023-01-13 20:28:05.870 INFO 4380 --- [ionShutdownHook] o.s.m.s.b.SimpleBrokerMessageHandler : Stopped.

Not able to connect to google cloud platform kafka from local host

I am trying to connect to kafka to an instance I have created in GCP.
I have started my VM in GCP
following are the configurations in server.properties
zookeeper.connect = {external-ip of VM}:2181
advertised.listeners=PLAINTEXT://{external-ip of VM}:9092
If I am starting my kafka by executing the command .\bin\windows\kafka-server-start.bat .\config\server.properties from kafka installed directory I am getting an error.
[2021-06-11 16:22:44,997] INFO Session: 0x0 closed
(org.apache.zookeeper.ZooKeeper) [2021-06-11 16:22:44,998] INFO
EventThread shut down for session: 0x0
(org.apache.zookeeper.ClientCnxn) [2021-06-11 16:22:45,000] INFO
[ZooKeeperClient Kafka server] Closed.
(kafka.zookeeper.ZooKeeperClient) [2021-06-11 16:22:45,005] ERROR
Fatal error during KafkaServer startup. Prepare to shutdown
(kafka.server.KafkaServer)
kafka.zookeeper.ZooKeeperClientTimeoutException: Timed out waiting
for connection while in state: CONNECTING
at kafka.zookeeper.ZooKeeperClient.$anonfun$waitUntilConnected$3(ZooKeeperClient.scala:271)
at kafka.zookeeper.ZooKeeperClient.waitUntilConnected(ZooKeeperClient.scala:267)
at kafka.zookeeper.ZooKeeperClient.<init>(ZooKeeperClient.scala:125)
at kafka.zk.KafkaZkClient$.apply(KafkaZkClient.scala:1948)
at kafka.server.KafkaServer.createZkClient$1(KafkaServer.scala:431)
at kafka.server.KafkaServer.initZkClient(KafkaServer.scala:456)
at kafka.server.KafkaServer.startup(KafkaServer.scala:191)
at kafka.Kafka$.main(Kafka.scala:109)
at kafka.Kafka.main(Kafka.scala) [2021-06-11 16:22:45,007] INFO shutting down (kafka.server.KafkaServer) [2021-06-11
16:22:45,014] INFO App info kafka.server for 0 unregistered
(org.apache.kafka.common.utils.AppInfoParser) [2021-06-11
16:22:45,015] INFO shut down completed (kafka.server.KafkaServer)
[2021-06-11 16:22:45,016] ERROR Exiting Kafka. (kafka.Kafka$)
[2021-06-11 16:22:45,018] INFO shutting down
(kafka.server.KafkaServer)
Also if I am pinging the internal IP of VM, I am not getting any response.

Spring Boot Application shown as UNKNOWN in Eureka server

I'm running an application with Spring (as Discovery Client app), also have a Discovery Server with Eureka, and Spring Cloud Config Server. When the client app is started it's registered as "UNKNOWN" in Eureka, despite its status is set to"UP", isn't able to get the properties from the configuration server.
Client App, Eureka server,and Config Server Spring Boot Version: 2.4.2
Client bootstrap.properties:
spring.application.name=config-client-app
spring.cloud.config.discovery.enabled=true
eureka.client.service-url.defaultZone=http://localhost:8761/eureka
eureka.instance.instance-id=${spring.application.name}
Client application.properties file:
logging.level.=debug
server.port=8900
eureka.client.healthcheck.enabled=true
Client Application Class:
#SpringBootApplication
#EnableDiscoveryClient
#RestController
public class ConfigClientAppApplication {
public static void main(String[] args) {
SpringApplication.run(ConfigClientAppApplication.class, args);
}
}
Eureka Serverproperties file:
spring.application.name=discovery-server
server.port=8761
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
Eureka Application class:
#EnableEurekaServer
#SpringBootApplication
public class DiscoveryServerApplication {
public static void main(String[] args) {
SpringApplication.run(DiscoveryServerApplication.class, args);
}
}
The log info:
restartedMain] c.n.discovery.InstanceInfoReplicator : InstanceInfoReplicator onDemand update allowed rate per min is 4
2021-02-09 16:02:50.388 INFO 2845 --- [ restartedMain] com.netflix.discovery.DiscoveryClient : Discovery Client initialized at timestamp 1612904570388 with initial instances count: 1
2021-02-09 16:02:50.390 INFO 2845 --- [ restartedMain] o.s.c.n.e.s.EurekaServiceRegistry : Registering application UNKNOWN with eureka with status UP
2021-02-09 16:02:50.391 INFO 2845 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : Saw local status change event StatusChangeEvent [timestamp=1612904570391, current=UP, previous=STARTING]
2021-02-09 16:02:50.391 INFO 2845 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_UNKNOWN/192.168.10.22:8900: registering service...
2021-02-09 16:02:50.391 WARN 2845 --- [ restartedMain] c.n.discovery.InstanceInfoReplicator : Ignoring onDemand update due to rate limiter
2021-02-09 16:02:50.393 INFO 2845 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8900 (http) with context path ''
2021-02-09 16:02:50.394 INFO 2845 --- [ restartedMain] .s.c.n.e.s.EurekaAutoServiceRegistration : Updating port to 8900
2021-02-09 16:02:50.413 INFO 2845 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_UNKNOWN/192.168.10.22:8900 - registration status: 204
I am using Spring cloud version
<spring-cloud.version>2021.0.5</spring-cloud.version>
and spring boot version
<version>2.7.5</version>
In application.properties, add the following lines to resolve the error:
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
By default, the Eureka Server registers itself into the discovery. The following 2 lines will tell eureka server that there is only one eureka server present in this context.
in the absence of these, our Eureka Server will try to find and register itself on other Eureka Servers in the context and throw a discovery client exception. i.e our own system.
If you encounter the below errors after adding the above properties only you need to add the below properties.
We must add this to the properties, if configuration is not required.
spring.cloud.config.enabled=false
Otherwise application will throw below exception.
No spring.config.import property has been defined
(or) If you have a other server, such as any configuration server we can add this optional server configuration to application.properties,
spring.config.import=optional:configserver: Your server url
Spring Cloud Config provides server and client-side support for
externalized configuration in a distributed system

Spring multiple Opened Connections

I set up a new Spring Boot Application including only the spring-boot-starter-data-mongodb dependency and added basic mongodb configs (host, port, username, password, ..) in the application.properties.
When I execute the application the following appears in the console:
2020-12-27 23:30:21.306 INFO 25230 --- [localhost:27017] org.mongodb.driver.connection : Opened connection [connectionId{localValue:1, serverValue:86}] to localhost:27017
2020-12-27 23:30:21.306 INFO 25230 --- [localhost:27017] org.mongodb.driver.connection : Opened connection [connectionId{localValue:2, serverValue:87}] to localhost:27017
I am curios why the connection was opened twice by spring. Isn't one opened connection enough?
Please add the below line into your properties file.
spring.data.mongodb.min-connections-per-host=1
The default size is 2 for the MongoDB java driver.
Hope this will work for you!

how can i create a camel webcocket client? Suggest some reference examples

I am trying to create a websocket client using camel.. Can we implement it using atmosphere websocket.I have referred the document in camel official site. Could you please provide some reference examples on to create a websocket client?
I also tried using ahc with the below code, and the server gets started with the below log,
but i get no response on the client side where the server is continuously sending data
from("ahc-ws://localhost:8180/receive/public")
.log(">>> Message received from WebSocket Client : ${body}")
.transform().simple("${body}${body}");```
Starting CamelMainRunController to ensure the main thread keeps running
2020-04-09 05:40:58.619 INFO 7636 --- [ main] o.a.camel.component.ahc.ws.WsEndpoint : Reconnecting websocket: ws://localhost:8180/ws/recieve/public
2020-04-09 05:40:58.636 INFO 7636 --- [inRunController] org.apache.camel.main.BaseMainSupport : Using properties from classpath:application.properties;optional=true
2020-04-09 05:41:00.309 INFO 7636 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Route: route1 started and consuming from: ahc-ws://localhost:8180/ws/recieve/public
2020-04-09 05:41:00.325 INFO 7636 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Total 1 routes, of which 1 are started
2020-04-09 05:41:00.326 INFO 7636 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Apache Camel 3.1.0 (CamelContext: camel-1) started in 3.845 seconds
2020-04-09 05:41:00.417 INFO 7636 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2020-04-09 05:41:00.429 INFO 7636 --- [ main] c.w.server.WebsocketClientApplication : Started WebsocketClientApplication in 60.888 seconds (JVM running for 66.527)

Categories

Resources