felixge / node-graphite

A node.js client for graphite.
106 stars 16 forks source link

Connect via UDP #19

Open MatzHilven opened 11 months ago

MatzHilven commented 11 months ago

Is it possible to connect to carbon via UDP? (using this client of course)

Serphentas commented 11 months ago

I believe you can, but by default carbon.conf has that feature disabled:

ENABLE_UDP_LISTENER = False
UDP_RECEIVER_INTERFACE = 0.0.0.0
UDP_RECEIVER_PORT = 2003

However, this client uses LazySocket that calls for a normal Socket creation which is only TCP. Support for UDP would require a PR at this stage.

Are you able to submit such a change ? If not, I can look into it.

MatzHilven commented 11 months ago

I'm not very experienced in js, but it looks like the net module has only got support for TCP clients. Seems like dgram would be good for this job?

Serphentas commented 11 months ago

That is correct, it's just a matter of calling the right type of socket within LazySocket, but this is outside the scope of this repo and I can only approve PRs here. Thus, I suggest we implement UDP support without dependencies as it's pretty straightforward.

I will think of a first draft to then use for tests and ping you when it's ready.

MatzHilven commented 11 months ago

Perfect, thanks!

Serphentas commented 10 months ago

I just pushed the initial version with UDP support on the feat-udp branch. Can you pull it and try locally ?

You will also need to change the connect string: replace plaintext with udp. See README for an example.

Serphentas commented 10 months ago

Any updates @MatzHilven ? If it works well, I will merge into master.

MatzHilven commented 10 months ago

I'll get you an answer this evening!

Serphentas commented 5 months ago

Shameless ping @MatzHilven :)

MatzHilven commented 5 months ago

Sorry for the delay!! LGTM 😊

Also: https://github.com/felixge/node-graphite/pull/20#issuecomment-1811197602