B4J Question MQTT Connection with SNI

tfcroft4

New Member
I am trying to run the sample MQTT Client connected to a HIVEMQ broker.
The client does connect to the public HIVEMQ broker OK and will send and receive messages.
Host:broker.hivemq.com
TCP Port:1883

The serverless connection is like this Host tcp://xxxxxxxxxx.s1.eu.hivemq.cloud port Port: 8883
When trying to connect I get: Error connecting: (EOFException) java.io.EOFException
HiveMQ support advise that The serverless broker requires TSL SNI connection protocol as this is a shared server.
Can someone suggest how this might be achieved using B4J.
Thanks
Ted
 

tfcroft4

New Member
Erel
Thanks for the reply.
I have tested the connection using the HiveMQ CLI tool. This is Java based and uses the Java Runtime Environment - that connects OK.
I have also tested using the Hive Javascript Client - that connects OK.
Using the B4J MQTT Client I can get a connection to the HiveMQ public broker using port 1883 which is one server at the IP address so does not need SNI.
As I understand it the serverless broker will need SNI as there are multiple servers at the one IP address.

I would take a look at the library code if I knew where it was, but I am no expert.
Ted
( I made two posts as I thought one was lost but was perhaps waiting for moderations - apologies.)
{The limitations of Javascript lead me back to B4J having already worked with B4A.}
 
Upvote 0

tfcroft4

New Member
I changed this line
ConnectTo:
client.Initialize("client", $"tcp://${Host}:${port}"$, "desktop" & Rnd(1, 10000000))
to
ConnectTo:
client.Initialize("client", $"ssl://${Host}:${port}"$, "desktop" & Rnd(1, 10000000))

replacing tcp with ssl

and the Client-connected callback returned success.

But Now this line

client_MessageArrived:
 Dim receivedObject As Object = serializator.ConvertBytesToObject(Payload)

is giving this error.: java.util.zip.ZipException: incorrect header check

But perhaps that is another story.
Ted
 
Upvote 0

tfcroft4

New Member
I think the MQTTClient code is making assumptions about the data sent and received.
The stored message I received from my server is a simple string so does not convert to an object.
I can simplify things for my own application.

I think this is resolved for now.
Thanks
Ted
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…