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

Azure IoT Hub Connector - Thingworx 8.4 - Connection Error

SOLVED
Regular Member

Azure IoT Hub Connector - Thingworx 8.4 - Connection Error

Hi All

 

I am having an issue connecting to the Azure IoT Hub from ThingWorx 8.4.

- The Connector and Thingworx are on the same server

- The attached azure-iot.conf file was configured using direction from PTC Using this link 

 

When run the azure-iot.bat file from cmd i get the following error. Any help with this issue is much appreciated! Thanks!

 

14:06:16.812 [NettyClient-NIO-5] ERROR c.t.s.i.t.netty.NettyBytesChannel - Error while establishing websocket connection on channel com.thingworx.sdk.impl.transport.netty.NettyBytesChannel$2@6069b8ae.
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(Unknown Source)
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(Unknown Source)

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Azure IoT Hub Connector - Thingworx 8.4 - Connection Error

Hi Harry, Please do it again in your test environment with following steps: 1.Change "HTTPRequestHeaderMaxLength": 5000 , in ThingworxPlatform/platform-settings.json (by default it is set to 2000) check from http://support.ptc.com/help/thingworx_hc/thingworx_8_hc/en/#page/ThingWorx%2FHelp%2FGetting_Started%... (sorry hyperlink to a text is not working on my side now so copying the total link) regarding how to set the HTTPRequestHeaderMaxLength parameter 2.Change Validator.HTTPHeaderValue=^[a-zA-Z0-9()\\-=\\*\\.\\?;,+\\/:&_ % \u00A1-\uFFFF'"]*$ in ThingworxStorage/esapi/validation.properties 3.After the changes, restart Tomcat server (choose the time for restarting when users will not be impacted) Hope this helps, Br, Anna
8 REPLIES 8

Re: Azure IoT Hub Connector - Thingworx 8.4 - Connection Error

Hi Anna,
I double checked the recommendations you shared and everything looks good to me. Please refer the attached files that you requested.
FYI- if I disable ssl and try to connect to things using ws://localhost:8080 or 127.0.0.1 the cxserver log starts growing like crazy, many gb's in couple mins.
Appreciate you taking the time to help me out.

Thanks
Harry

Re: Azure IoT Hub Connector - Thingworx 8.4 - Connection Error

Hello,

 There are three possibilities I could imagine to cause this issue:

1. Not setting correct Connection server system variables.

Look here to know how to set it properly

2. Configure wrong AppKey or ThingWorx url in transport.websockets in your connector conf file. Please check again to make sure it's accessing the correct port;

3. if still not work for 1,2, try to use 127.0.0.1 instead of hostname, maybe there is some hostname resolving issue when accessing from same machine, but I'm not sure about this.

 

There is an article mentioning similar issue for your reference.

Hope it helps,

 

Thanks,

 

Br,

Anna

Re: Azure IoT Hub Connector - Thingworx 8.4 - Connection Error

Hi Anna,
I double checked the recommendations you shared and everything looks good to me. Please refer the attached files that you requested.
FYI- if I disable ssl and try to connect to things using ws://localhost:8080 or 127.0.0.1 the cxserver log starts growing like crazy, many gb's in couple mins.

FYI- I am also using the same port (8080) for connection to KepServer


Appreciate you taking the time to help me out.

Thanks
Harry

Re: Azure IoT Hub Connector - Thingworx 8.4 - Connection Error

Are you running the Connector on the same machine as Thingworx itself?  I assume so, but it's not clear from your problem description.

 

-Chris Kaminski

Highlighted

Re: Azure IoT Hub Connector - Thingworx 8.4 - Connection Error

yes on the same machine..So is KepServer  that is connecting on the same port (8080)

Re: Azure IoT Hub Connector - Thingworx 8.4 - Connection Error

Hi Harry,

I see in ApplicationLog there is some thread deadlock occurred, and is it related to this issue? 

Also I see you have used an ssl connection to ThingWorx platform in azure-iot.txt, and a secure websocket connection to ThingWorx was failed because of this. Could you try to restart ThingWorx and re-configure azure-iot.conf file to use http instead of https and see the issue is gone or not? if issue is still there, please send out the 4 files again.

Finally, I recommend you prepare a clean(better fresh installed with no data, no extension, no connection to other clients) ThingWorx on another machine and try to connect again.

 

Thanks,

Br,

Anna

 

Br,

Anna

Re: Azure IoT Hub Connector - Thingworx 8.4 - Connection Error

Hi Anna - Thanks for your help. At this point i am able to connect to IoT hub, however,  i am seeing the errors below in the logs. I have attached the conf and the log files for your reference. Thank-you!

 

Application log:

2019-04-30 09:07:17.540-0400 [L: ERROR] [O: E.c.t.s.f.ValidatingHttpRequest] [I: ] [U: Administrator] [S: ] [T: http-nio-8080-exec-23] Error occurred while validating HTTP header: cookie. HTTP header value: cookie: Invalid input. Please conform to regex ^[a-zA-Z0-9()\-=\*\.\?;,+\/:&_|% ]*$ with a maximum length of 2000

 

Error Log:

2019-04-30 09:09:49.417-0400 [L: ERROR] [O: E.c.t.s.f.ValidatingHttpRequest] [I: ] [U: Administrator] [S: ] [T: http-nio-8080-exec-16] Error occurred while validating HTTP header: cookie. HTTP header value: cookie: Invalid input. Please conform to regex ^[a-zA-Z0-9()\-=\*\.\?;,+\/:&_|% ]*$ with a maximum length of 2000

 

cx-server: (this was registered after i tried to import the device in IoT Hub)

09:05:05.419 [AzureExportThread] ERROR c.t.p.azure.iot.HubImportHandler - Error exporting hub thing names
com.microsoft.azure.storage.StorageException: Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
at com.microsoft.azure.storage.StorageException.translateFromHttpStatus(StorageException.java:175)
at com.microsoft.azure.storage.StorageException.translateException(StorageException.java:94)
at com.microsoft.azure.storage.core.StorageRequest.materializeException(StorageRequest.java:305)
at com.microsoft.azure.storage.core.ExecutionEngine.executeWithRetry(ExecutionEngine.java:175)
at com.microsoft.azure.storage.blob.CloudBlobContainer.exists(CloudBlobContainer.java:769)
at com.microsoft.azure.storage.blob.CloudBlobContainer.createIfNotExists(CloudBlobContainer.java:379)
at com.microsoft.azure.storage.blob.CloudBlobContainer.createIfNotExists(CloudBlobContainer.java:326)
at com.thingworx.protocol.azure.iot.HubImportHandler$AzureExportJob.run(HubImportHandler.java:211)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

Re: Azure IoT Hub Connector - Thingworx 8.4 - Connection Error

Hi Harry, Please do it again in your test environment with following steps: 1.Change "HTTPRequestHeaderMaxLength": 5000 , in ThingworxPlatform/platform-settings.json (by default it is set to 2000) check from http://support.ptc.com/help/thingworx_hc/thingworx_8_hc/en/#page/ThingWorx%2FHelp%2FGetting_Started%... (sorry hyperlink to a text is not working on my side now so copying the total link) regarding how to set the HTTPRequestHeaderMaxLength parameter 2.Change Validator.HTTPHeaderValue=^[a-zA-Z0-9()\\-=\\*\\.\\?;,+\\/:&_ % \u00A1-\uFFFF'"]*$ in ThingworxStorage/esapi/validation.properties 3.After the changes, restart Tomcat server (choose the time for restarting when users will not be impacted) Hope this helps, Br, Anna