Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

NiFi WebSocket Headers

avatar

I need to pass headers in order make a WebSocket connection.

How can I do this in NiFi?

jacektrocinski_0-1673945949528.png

 

1 ACCEPTED SOLUTION

avatar

Here's the way to do it:

 

Connect GenerateFlowFile processor (with FF attributes) to ConnectWebSocket.

View solution in original post

8 REPLIES 8

avatar
Master Collaborator

You can use InvokeHTTP processor wich provide options to handle Header 

 

Thank you

avatar

@ckumar No, that won't work, I'm trying to invoke a WebSocket URL: wss://api.gemini.com/v1/order/events

InvokeHTTP can't create WebSocket connections.

avatar
Master Collaborator

Ah my bad, for the WebSocket end point did you try ConnectWebSocket ?

avatar

@ckumar Yes, I am using ConnectWebSocket but how do I pass a custom header like X-GEMINI-APIKEY to the initial connection?

avatar

Here's the way to do it:

 

Connect GenerateFlowFile processor (with FF attributes) to ConnectWebSocket.

avatar
Master Collaborator

ConnectWebSocket does not read any details from Flow file attribute from an incoming flow file.

If you are a Cloudera customer, feel free to file a support ticket with us, we should be able to help you on this with a longer engagement.  

 

Thank you 

avatar

@ckumar That is incorrect, the ConnectWebSocket reads attributes from an incoming flow file.

It is also in the documentation that I posted:

https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-websocket-processors-nar/1.19...

I contacted a Cloudera NiFi expert and he confirmed.

The solution I posted is correct.

avatar
Master Collaborator

@jacektrocinski Yes, Sir, you are right,  I put more focus on read attribute section of the document which has none but missed seeing Additional details. 

Kudos!!