Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

original input msg obj gets lost #1

Open
protonmw opened this issue Mar 4, 2024 · 4 comments
Open

original input msg obj gets lost #1

protonmw opened this issue Mar 4, 2024 · 4 comments
Assignees
Labels
enhancement New feature or request question Further information is requested

Comments

@protonmw
Copy link

protonmw commented Mar 4, 2024

The original input msg object with all other information (for example return node information) is getting lost.
The better way would be to update msg.payload and keep the other information.

@jorgen-k
Copy link
Owner

jorgen-k commented Mar 7, 2024

The original input msg object with all other information (for example return node information) is getting lost. The better way would be to update msg.payload and keep the other information.

Please update with information on what you try to do. If possible add an example showing the faulty behaviour.

@jorgen-k jorgen-k self-assigned this Mar 7, 2024
@jorgen-k jorgen-k added the question Further information is requested label Mar 7, 2024
@protonmw
Copy link
Author

Input object:
image

Output object:
image

The tcp node creates a new msg object, instead of changing the payload. Therefore all other information like "_linksource" are getting lost. Put the tcp node between link_in and link_out nodes (to create a function) to see the behaviour. I stored this manually in the screenshot below.

image
image

@jorgen-k
Copy link
Owner

I see your point.

In different applications, servers might emit data sporadically or may not respond in a timely manner, or will automacially emit a lot of data without any data from the client. This necessitates a TCP client design that can gracefully handle such variability. This includes the ability to manage data that arrives without a direct request as well as requests not resulting in any data.

To accommodate these diverse situations it will not be possible to always justs anhance the message object with payload.

To do this we could pursue a strategy that involves storing incoming message objects upon receipt. Should the server provide a response, the system update the payload of the stored message object, rather than creating a new one. If multiple messages are emitted, the same applies for all messages. Of course this behaviour must be configurable since it could have unwanted side effects.
The proposed approach is encapsulated in the following operational scenarios:

Client-Server Data Receipt:

  • Given the feature is enabled and the client is connected to a server,
  • When the tcp-client receives data,
  • Then the data payload is forwarded to the server, and all other data is retained within the client for contextual integrity.

Server Data Emission:

  • Given the feature is enabled and the client is connected to a server,
  • When the server emits data,
  • Then the emitted data is enriched with the retained data, if available, preserving the full context of the communication.

@jorgen-k jorgen-k added the enhancement New feature or request label Mar 20, 2024
@protonmw
Copy link
Author

protonmw commented Mar 21, 2024

I see your point too ;-)

I was used to this behaviour of the standard TCP request node, so it would be nice to have this feature implemented.
Since im not a js programmer but only a "stupid" node red user, I can´t help really much on this.

But I think I´ve found the code of the built in tcp node (especially line 646 and following):
https://github.com/node-red/node-red/blob/master/packages/node_modules/%40node-red/nodes/core/network/31-tcpin.js
Perhaps this helps?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants