cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Connect Azure IoT Hub to ThingWorx - azure-iot.bat

Alexandrite

Connect Azure IoT Hub to ThingWorx - azure-iot.bat

Hi Developers,

 

I received this question from a user. Any recommendations? Thanks in advance.

---------------

I get another error when i run the next step azure-iot.bat...

 

14:57:01.520 [main] INFO c.t.f.i.AbstractManyPlatformWebSocketFabric - Many Platform WebSocket Fabric enabled without service discovery: endpoints=[ws://localhost:8080/Thingworx/WS]
14:57:01.555 [main] INFO c.t.s.i.transport.MuxingBytesChannel - Subchannel ws://localhost:8080/Thingworx/WS-1 in channel ws://localhost:8080/Thingworx/WS was no longer valid - unregistering 
it
14:57:01.555 [main] INFO c.t.s.i.transport.MuxingBytesChannel - Subchannel ws://localhost:8080/Thingworx/WS-2 in channel ws://localhost:8080/Thingworx/WS was no longer valid - unregistering 
it
14:57:01.555 [main] INFO c.t.s.i.transport.MuxingBytesChannel - Subchannel ws://localhost:8080/Thingworx/WS-3 in channel ws://localhost:8080/Thingworx/WS was no longer valid - unregistering 
it
14:57:01.555 [main] INFO c.t.s.i.transport.MuxingBytesChannel - Subchannel ws://localhost:8080/Thingworx/WS-4 in channel ws://localhost:8080/Thingworx/WS was no longer valid - unregistering 
it
14:57:01.555 [main] INFO c.t.s.i.transport.MuxingBytesChannel - Subchannel ws://localhost:8080/Thingworx/WS-5 in channel ws://localhost:8080/Thingworx/WS was no longer valid - unregistering 
it
14:57:01.555 [main] INFO c.t.s.i.transport.MuxingBytesChannel - Needed to reconnect subchannels on client endpoint [id: ws://localhost:8080/Thingworx/WS] : [active: 0, max: 5]
14:57:01.617 [main] INFO c.t.connectionserver.PlatformImpl - Starting ConnectionServer: UUID=092baf65-8a0e-41a4-be53-d0296d76662e, Platform protocol=V1, Platform transport=WEBSOCKETS
14:57:01.617 [main] INFO c.t.connectionserver.PlatformImpl - Waiting for connection to platform...
14:57:02.701 [NettyClient-NIO-4] ERROR c.t.s.i.t.netty.NettyBytesChannel - Error while establishing websocket connection on channel com.thingworx.sdk.impl.transport.netty.NettyBytesChannel$2@
4bc70f42.
java.net.ConnectException: Connection refused: no further information: localhost/127.0.0.1:8080
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
at io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:224)
at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:289)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:528)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112)
at java.lang.Thread.run(Thread.java:748)
14:57:02.701 [NettyClient-NIO-1] ERROR c.t.s.i.t.netty.NettyBytesChannel - Error while establishing websocket connection on channel com.thingworx.sdk.impl.transport.netty.NettyBytesChannel$2@
22a04d8a.
java.net.ConnectException: Connection refused: no further information: localhost/127.0.0.1:8080
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
at io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:224)
at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:289)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:528)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112)
at java.lang.Thread.run(Thread.java:748)
14:57:02.701 [NettyClient-NIO-2] ERROR c.t.s.i.t.netty.NettyBytesChannel - Error while establishing websocket connection on channel com.thingworx.sdk.impl.transport.netty.NettyBytesChannel$2@
168ff519.

11 REPLIES 11

Re: Connect Azure IoT Hub to ThingWorx - azure-iot.bat

I see a reference to 127.0.0.1:8080 which is where Tomcat/Thingworx would be, so I'm not sure if it is configured right. Are they running the connection server on the same box as Thingworx is running? There might be port conflicts potentially.

I'm not even sure if it is getting to the attempt to connect to Azure.

Sorry I am just going by what I read, I haven't done a ton with connection servers/iot hub connectors.

Re: Connect Azure IoT Hub to ThingWorx - azure-iot.bat

Hi PaiChung, Thank you. I am a newbee here. I am just trying to follow the steps on this guide

'https://developer.thingworx.com/resources/guides/azure-iot-hub-connector-quickstart/install-iot-hub-...'

I believe i have configured all except 

platform.extensions {
// Filesystem location of extension zips. This is needed for the connector to deploy extensions to the platform
location = "/opt/connector-bundle/extensions"
}

Because the guide didn't mention it.

I don't know what 'Tomcat/Thingworx' is yet and the guide didn't mention it. 

where should i start to debug this problem.

Thank you.

Re: Connect Azure IoT Hub to ThingWorx - azure-iot.bat

@henok were you able to resolve this issue. Seems like i am doing the same thing you are by using the connector  on the same pc where Thingworx in installed.

 

 

Re: Connect Azure IoT Hub to ThingWorx - azure-iot.bat

Hi, Yes i did. One of the issues was that the database name in Azure has to be all small letters:-)

Re: Connect Azure IoT Hub to ThingWorx - azure-iot.bat

yep thats one of the things I learnt while browsing the issues faced by others. 

 

Did you end up using the same pc to run your connector and thingworx environment? if yes, how did work around the port issue that @PaiChung mentioned.

Re: Connect Azure IoT Hub to ThingWorx - azure-iot.bat

Hi, I don't remember if that was a problem. I see now on the config that i am using "ws://localhost:80/Thingworx/WS". 

Re: Connect Azure IoT Hub to ThingWorx - azure-iot.bat

hmmm.. i've tried that too but not luck. Would you be open to sharing your conf file, without the keys ofcourse :-) 

Re: Connect Azure IoT Hub to ThingWorx - azure-iot.bat

Hi, when i delete the keys and names there is no much left:-), but if you want you can send me your and i can compare the content.

cx-server {
protocol {

// You can find the configuration parameters for your IoT Hub by logging into portal.azure.com and following the hints below.
// If necessary, create a new IoT Hub: https://azure.microsoft.com/en-us/documentation/articles/iot-hub-java-java-getstarted/

// A policy name that is related to a key specified below. This policy is typically a built in, pre defined policy called "service",
// but it is possible to use a custom policy if you add it to your hub.
// All resources > your-hub > Settings > Shared access policies > service (or custom service with "service connect" permission
consumerPolicyName = "service"

// A key that supplies credentials to access services specified in the related policy.
// All resources > your-hub > Settings > Shared access policies > {consumerPolicyName} > Primary (or Secondary) key
consumerPolicyKey = "xxxxxxxxxxxxxxx"

// A policy name that is related to the key specified below. This policy is typically a built in, predefined policy called
// "registryReadWrite", but it is possible to use a custom policy if you add it to your hub.
// The shared access policy requires the registry read and registry write permissions.
registryPolicyName = "registryReadWrite"

// A key that supplies credentials to access services specified in the related policy.
registryPolicyKey= "xxxxxxxxxxxxxxxxxxxxxxxx"

// A name that defines the IoT Hub related to this adapter, which manages your things and their related messages.
// Hubs can be scaled via hub units at different price tiers per unit. Hubs are related to a resource group, which is
// related to a subscription Id and a cloud Location.
// *** If the hub name EXCEEDS 25 CHARACTERS in length, be sure to change the eventHubName below accordingly ***
hubName = "xxxxxxxxxxxxxxx"

// The Event Hub-compatible name utilized by SDKs and integrations that expect to read from Event Hubs. An Event Hub is an internal
// component of an IoT Hub that handles device to cloud events for related things. In many cases the IoT Hub name and
// Event Hub-compatible name are the same, so default to the IoT Hub name. Note that long hub names require special care here.
// All resources > your-hub > Messaging > Endpoints > Events(built-in endpoint) > Event Hub-compatible name
eventHubName = xxxxx

// A built-in endpoint (Name=Events) utilized by SDKs and integrations that expect to read from Event Hubs.
// All resources > your-hub > Messaging > Endpoints > Events(built-in endpoint) > Event Hub-compatible endpoint (hostname without ".servicebus.windows.net")
eventHubNamespace = "xxxxxxxxxxxxxxx"

// A consumer group name is required to pull data from the IoT Hub.
// All resources > your-hub > Settings > Message > Consumer groups
// null means to use the $Default consumer group
consumerGroup = null

// IoT Hubs have a hostname that is defined by the hubName, plus a domain name of Azure's choosing, normally azure-devices.net.
// All resources > your-hub > Overview > Essentials section > Hostname
hubHostname = "xxxxxxxxxxxxxxxxx"

// Settings for Azure blob storage. Used for device-export for an Azure IoT Hub.
// Create a "Storage Account" in the Azure portal, then use the navigation hints below.
blob-storage {
accounts {
default {
// <blob-store> > Settings > Access Keys > Storage account name
account-name = "thingworxtest"
// <blob-store> > Settings > Access Keys > key1 or key2
account-key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}

}
event-processor-host {
container-name = "eph-storage-"${cx-server.protocol.eventHubName}
account = default
}
}
}

transport.websockets {
// ThingWorx platform application key
app-key = "xxxxxxxxxxxxxxxxxxxxxxxx"

// One or more platforms can be specified here, comma separated
platforms = "ws://localhost:80/Thingworx/WS"
}

platform.extensions {
// Filesystem location of extension zips. This is needed for the connector to deploy extensions to the platform
location = "/opt/connector-bundle/extensions"
}

}

Re: Connect Azure IoT Hub to ThingWorx - azure-iot.bat

Thanks for taking the time @henok . File attached for your reference. Thanks!