drachtio/drachtio-srf

Trace of messages between client & server

IdlePhysicist opened this issue · 5 comments

I am trying to get an output of all messages exchanged between the client and server (as per the docs).

// this will cause all messages between client and server to be logged to a file
srf.set('api logger', '/tmp/messages.log');

But the problem is that I am not seeing this /tmp/messages.log file on either my workstation where the client runs, or in the docker container where the server is running. Do you have any insight into this? Thanks.

hmm, I think I may have deprecated this feature a while back....let me check

Hi @davehorton have you got any update on this? The reason I am trying to log the messages is that I am working on a Go library for Drachtio, that was initially suggested in drachtio-server issue #40.

Not totally sure if this will work, but I think you can add a 'logger' property to your connect opts which is a function that should be called every time we are sending or receiving something over the socket, and it will get passed that data (along with a prefix, see links below) which you can then write to a file or whatever

e.g.

function logger(data) {
  console.log(data);
}

srf.connect({host, port, secret, logger});

see here, here, and here

FYI something I have thought would be nice in the future would be to change this messaging to use bencode. No immediate plans to do so, though, and that would be a major release / breaking change.

Thanks Dave! That seems to do the trick. I think the bencode could be interesting I appreciate the heads up.