How can I configure Connect and read timeout in apache CloseableHttpClient?
Related
I am running mosquitto on Windows, and configured it to work as mqtt on port 1883, and websockets on port 9001. I thought I could publish a message from an mqtt client and receive it on a websockets client, but it appears not to be so.
I can successfully deliver a message from an mqtt client to another mqtt client, as well as from a websockets client to another websockets client. All in all, there seems to be a impassable boundary between the two protocols.
Is this a limitation of Mosquitto?
Have I forgotten to set something in the conf file?
Note: I invoke Mosquitto with a -v option, so it logs verbosely. I have noticed that it actually logs connections and messages for websockets clients, but not for mqtt clients, although on mqtt client side everyting regarding connection and publishing seems ok (I am using MQTTNet client to publish, either in mqtt or in websockets mode, and PAHO javascript client, in websockets mode, for subscribing/receiving).
Disabling or enabling the firewall didn't make any difference.
Edit:
Here is the relevant section on the conf file:
listener 1883
protocol mqtt
listener 9001
protocol websockets
password_file mypasswordfile.pwd
This is what it reports when I launch it:
prompt> ./mosquitto -c myconfig.conf -v
2022-10-15 20:25:53: mosquitto version 2.0.15 starting
2022-10-15 20:25:53: Config loaded from myconfig.conf.
2022-10-15 20:25:53: Opening ipv6 listen socket on port 1883.
2022-10-15 20:25:53: Opening ipv4 listen socket on port 1883.
2022-10-15 20:25:53: Opening websockets listen socket on port 9001.
2022-10-15 20:25:53: mosquitto version 2.0.15 running
This is the relevant code fragment from the publisher (but I have also tried the mosquitto_pub utility):
var mqttFactory = new MqttFactory();
var mqttClient = mqttFactory.CreateMqttClient();
var mqttClientOptions = new MqttClientOptionsBuilder().
// WithTcpServer("localhost"). // This does NOT work
WithWebSocketServer("ws://localhost:9001/mqtt"). // This works
WithProtocolVersion(MQTTnet.Formatter.MqttProtocolVersion.V311).
WithClientId("publisher-client-id").
WithCredentials("myusername", "mypassword").
Build();
mqttClient.ConnectAsync(mqttClientOptions, CancellationToken.None).Wait();
var builder = new MqttApplicationMessageBuilder();
var applicationMessage = builder
.WithTopic("mytopic")
.WithPayload("mypayload")
.Build();
mqttClient.PublishAsync(applicationMessage, CancellationToken.None).Wait();
and here is a code fragment from the subscriber:
mqttConnect() {
this._mqtt = new Paho.MQTT.Client('localhost', 9001, '/mqtt', 'subscriber-client-id');
this._mqtt.onConnectionLost = this.onMqttConnectionLost.bind(this);
this._mqtt.onMessageArrived = this.onMqttMessageReceived.bind(this);
const options = {
mqttVersion: 4,
userName: 'myusername',
password: 'mypassword',
onSuccess: this.onMqttConnected.bind(this),
onFailure: this.onMqttFailedConnecting.bind(this)
};
this._mqtt.connect(options);
...
}
onMqttConnected() {
console.log('Connected to MQTT broker');
...
this._mqtt.subscribe('mytopic');
}
onMqttMessageReceived(message) {
console.log('Received MQTT message; topic = ' + message.destinationName + ', payload = ' + message.payloadString);
...
}
As thrashed out in the comments, there were 2 instance running (one the Windows service, one in the command prompt).
Shutting down the background service fixed the problem.
(It is unclear why both instances were able to bind to port 1883)
We have configured WLP and MQ to use JMS messaging. On a server1 where the Liberty Servers and MQ installed we referred the MQ libraries as below and it's working fine. However, we are not sure from server2 when we make connection to MQ we are using client transport type with port number. How to refer the below MQ libraries on the server2 server.xml? Any help or guidance on this? Thanks
server.xml from server1
server2 JMS connection
<properties.wmqJms
transportType="CLIENT"
hostName="Host1"
port="9001"
channel="SYSTEM.DEF.SVRCONN"
queueManager="QM1"/>
You'll need to copy the file wmq.jmsra.rar to the disk of server2 and then set the path to that file in server.xml using a variable:
<variable name="wmqJmsClient.rar.location" value="/path/to/wmq/rar/wmq.jmsra.rar"/>
See: https://www.ibm.com/docs/en/was-liberty/nd?topic=dmal-deploying-jms-applications-liberty-use-mq-messaging-provider
I configured ssl on springboot correctly:
server.port=8443
server.ssl.key-store=classpath:springboot.p12
server.ssl.key-store-password=*****
server.ssl.key-store-type=PKCS12
It always says the same whatever port I try:The Tomcat connector configured to listen on port 8443 failed to start. The port may already be in use or the connector may be mis-configured. Action:Verify the connector's configuration, identify and stop any process that's listening on port 8443, or configure this application to listen on another port. Springboot will not start the application, it's so terrible as a framework with no way to debug it.
Any experienced developer could know such a bug that stuck me forever?!
Its apache2 use it:
SSLEngine On
SSLCertificateFile /abc.crt
SSLCertificateKeyFile /abc.key
SSLCertificateChainFile /abc.ca-bundle
It has to use this way exactly to make it work:
https://mkyong.com/spring-boot/spring-boot-ssl-https-examples/
I'm running HAproxy with backend Spring Boot Rest controllers. My spring log shows constant errors that look like the following:
[reactor-http-epoll-26] ERROR o.s.w.s.a.HttpWebHandlerAdapter - [9df8bfcf] Error [io.netty.channel.unix.Errors$NativeIoException: writeAddress(..) failed: Connection reset by peer] for HTTP GET "/api/v1/status", but ServerHttpResponse already committed (200 OK)
HAproxy performs an HTTP check on the url /api/v1/status. What would be the reason that I'm getting these errors?
HAProxy Config
global
log 127.0.0.1 local2
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 4000
user haproxy
group haproxy
# daemon
# turn on stats unix socket
stats socket /var/lib/haproxy/stats
ssl-default-bind-ciphers EECDH+ECDSA+AESGCM:EECDH+aRSA+AESGCM:EECDH+ECDSA+SHA384:EECDH+ECDSA+SHA256:EECDH+aRSA+SHA384:EECDH+aRSA+SHA256:EECDH+aRSA+RC4:EECDH:EDH+aRSA:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EX$
ssl-default-bind-options no-sslv3 no-tlsv10
tune.ssl.default-dh-param 4096
defaults
mode http
log global
option httplog
option http-server-close
option forwardfor except 127.0.0.0
option redispatch
retries 3
timeout http-request 30s
timeout queue 1m
timeout connect 30s
timeout client 30s
timeout server 30s
frontend https-in
bind *:443 ssl crt /etc/cert.pem
default_backend api
backend api
mode http
option httpchk GET /api/v1/status HTTP/1.0
http-check expect status 200
balance roundrobin
server api1 127.0.0.1:8001 check fall 3 rise 2
server api2 127.0.0.1:8002 check fall 3 rise 2
HAproxy is doing GET request, reads http response code and closing connection.
Boot is trying to send remaining parts (http headers and some json payload) but connection is already closed.
Just replace GET with OPTIONS in the line:
option httpchk GET /api/v1/status HTTP/1.0
I've set up a mosquitto broker but it refuses to connect over websockets
here is my conf file:
# Place your local configuration in /etc/mosquitto/conf.d/
#
# A full description of the configuration file is at
# /usr/share/doc/mosquitto/examples/mosquitto.conf.example
pid_file /var/run/mosquitto.pid
persistence true
persistence_location /var/lib/mosquitto/
log_dest file /var/log/mosquitto/mosquitto.log
include_dir /etc/mosquitto/conf.d
listener 1883 0.0.0.0
listener 8008 0.0.0.0
protocol websockets
and I don't have any conf at conf.d
Using the PAHO javascript client I get a ERR_CONNECTION_REFUSED
by the way I'm using debian jessie as OS
-------------------------------------EDIT 1----------------------------------
I've lowered the iptables and it still not working.
The usual way to connect is working (with port 1883)
Here is the output when I start mosquitto
1477788244: mosquitto version 1.4.10 (build date Thu, 25 Aug 2016 10:12:09 +0100) starting
1477788244: Using default config.
1477788244: Opening ipv4 listen socket on port 1883.
1477788244: Opening ipv6 listen socket on port 1883.
The important line in the startup output is here:
1477788244: Using default config.
This says that mosquitto is using it's built in config (only listen on 1883 for native MQTT traffic) and not even reading your config file.
If you just start mosquitto with no command line options this is what is uses, it will not look for a config file in /etc/mosquitto/.
You need to explicitly tell mosquitto where it's config file with the -c option.
mosquitto -c /etc/mosquitto/mosquitto.conf
Depending on how you installed mosquitto you may need to edit the scripts that automatically start it on boot. This is probably in here: /etc/init.d/mosquitto