• United States
IBM?
  • Site map
IBM?
  • Marketplace

  • Close
    Search
  • Sign in
    • Sign in
    • Register
  • IBM Navigation
IBM Developer Answers
  • Spaces
    • Blockchain
    • IBM Cloud platform
    • Internet of Things
    • Predictive Analytics
    • Watson
    • See all spaces
  • Tags
  • Users
  • Badges
  • FAQ
  • Help
Close

Name

Community

  • Learn
  • Develop
  • Connect

Discover IBM

  • ConnectMarketplace
  • Products
  • Services
  • Industries
  • Careers
  • Partners
  • Support
10.190.13.206

Internet of Things×

Refine your search by using the following advanced search options.

Criteria Usage
Questions with keyword1 or keyword2 keyword1 keyword2
Questions with a mandatory word, e.g. keyword2 keyword1 +keyword2
Questions excluding a word, e.g. keyword2 keyword1 -keyword2
Questions with keyword(s) and a specific tag keyword1 [tag1]
Questions with keyword(s) and either of two or more specific tags keyword1 [tag1] [tag2]
To search for all posts by a user or all posts with a specific tag, start typing and choose from the suggestion list. Do not use a plus or minus sign with a tag, e.g., +[tag1].
  • Ask a question

IBM IoT output node to websockets end-point

270007ATS3 gravatar image
Question by Nagesh_S  (30) | Jul 19, 2018 at 11:23 PM watsoniotmqttwebsockets

In my Node-RED flow, I have wired an IBM IoT Input node to an IBM IoT Output node. I am using mosquitto_pub to publish to WIoTP so that the Node-RED flow is started. Similarly, I am using mqtt sub (from mqttjs) to subscribe to the message from the Node-RED flow. However, I am not receiving payload on my subscription terminal window.

Publish

 mosquitto_pub -h orgId.messaging.internetofthings.ibmcloud.com -p 8883 -i d:orgId:dType:default -u use-token-auth -P 'authToken' --cafile messaging.pem -t iot-2/evt/data/fmt/json -f payload.json

The IBM Input node subscribes to this device's ( d:orgId:dType:default ) data and forwards it to the IBM Output node where the device type is set to mobile and event type is set to live.

Subscribe

 mqtt sub -h orgId.messaging.internetofthings.ibmcloud.com -p 443 -l wss -i a:orgId:default_mobile -u API-key -P 'API-token' --ca messaging.pem -t iot-2/type/mobile/id/default_mobile/evt/live/fmt/json

For subscription, I have created API keys and am using the same. What am I missing?

People who like this

  0
Comment
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster

4 answers

  • Sort: 
270007ATS3 gravatar image
Accepted answer

Answer by Nagesh_S (30) | Jul 20, 2018 at 12:14 PM

Thanks to @idan this problem is now resolved!

  1. Devices (beginning with a d:) can subscribe to iot-2/cmd topic strings only.

  2. I had wired the input node to output node directly. Therefore, all the settings in the output node were being overridden with msg. attributes. So, I put in a function node that sets the msg. attributes. Alternatively (as suggested by @idan), the function node can have a single line as msg=msg.payload so that the attributes in the node are not overridden.

Comment

People who like this

  0   Share
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
270003TGA5 gravatar image

Answer by idani (624) | Jul 20, 2018 at 01:45 AM

the topic to which you subscribe does not look ok:

iot-2/type/mobile/id/default_mobile/evt/live/fmt/json

If you publish to iot-2/evt/data/fmt/json the the topic should look like (assuming that device type is mobile and device if is default_mobile)::

iot-2/type/mobile/id/default_mobile/evt/data/fmt/json

Comment

People who like this

  0   Share
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
270007ATS3 gravatar image

Answer by Nagesh_S (30) | Jul 20, 2018 at 03:38 AM

The IBM Output node has event type set to live and device type set to mobile. That is why I am subscribing to iot-2/type/mobile/id/default_mobile/evt/live/fmt/json. And, the key point here is, to subscribe to this topic string over Websockets ( wss ).

Comment

People who like this

  0   Share
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
550000Q2HS gravatar image

Answer by averydxf (1) | Aug 24, 2018 at 03:51 AM

great website.

Comment

People who like this

  0   Share
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster

Follow this question

150 people are following this question.

Answers

Answers & comments

Related questions

mosquitto_ clients won't connect from AWS EC2. 2 Answers

Handling connect and disconnects with Watson IoT Platform 3 Answers

Internet of Things – IBM MQTT Servers, IBM IoT Foundation (BlueMix hosted) & IIB 1 Answer

IoT Watson Device Management: reboot request fails 1 Answer

How to communicate to beagle bone black using watson iot platform? 1 Answer

  • Contact
  • Privacy
  • IBM Developer Terms of use
  • Accessibility
  • Report Abuse
  • Cookie Preferences

Powered by AnswerHub

Authentication check. Please ignore.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • API Connect
  • Analytic Hybrid Cloud Core
  • Application Performance Management
  • Appsecdev
  • BPM
  • Blockchain
  • Business Transaction Intelligence
  • CAPI
  • CAPI SNAP
  • CICS
  • Cloud Analytics
  • Cloud Automation
  • Cloud Object Storage
  • Cloud marketplace
  • Collaboration
  • Content Services (ECM)
  • Continuous Testing
  • Courses
  • Customer Experience Analytics
  • DB2 LUW
  • DataPower
  • Decision Optimization
  • DevOps Services
  • Developers IBM MX
  • Digital Commerce
  • Digital Experience
  • Finance
  • Global Entrepreneur Program
  • Hadoop
  • Hybrid Cloud Core
  • IBM Cloud platform
  • IBM Design
  • IBM Forms Experience Builder
  • IBM Maximo Developer
  • IBM StoredIQ
  • IBM StoredIQ-Cartridges
  • IIDR
  • ITOA
  • InformationServer
  • Integration Bus
  • Internet of Things
  • Kenexa
  • Linux on Power
  • LinuxONE
  • MDM
  • Mainframe
  • Messaging
  • Node.js
  • ODM
  • Open
  • PowerAI
  • PowerVC
  • Predictive Analytics
  • Product Insights
  • PureData for Analytics
  • Push
  • QRadar App Development
  • Run Book Automation
  • Search Insights
  • Security Core
  • Storage
  • Storage Core
  • Streamsdev
  • Supply Chain Business Network
  • Supply Chain Insights
  • Swift
  • UBX Capture
  • Universal Behavior Exchange
  • UrbanCode
  • WASdev
  • WSRR
  • Watson
  • Watson Campaign Automation
  • Watson Content Hub
  • Watson Marketing Insights
  • dW Answers Help
  • dW Premium
  • developerWorks Sandbox
  • developerWorks Team
  • Watson Health
  • More
  • Tags
  • Questions
  • Users
  • Badges