Does anyone know how I can set a timeout for the tcp socket in xmpp.js?
Daniel
whatever the default timeout for connection establishment is seems to be too low for my usecase
mikeyehas left
asterixhas left
asterixhas joined
suohuahas left
machas left
adityaborikarhas left
Kevhas left
Kevhas joined
Kevhas left
Kevhas joined
suohuahas joined
suohuahas left
florettahas joined
lovetoxhas left
sonnyhas joined
adityaborikarhas joined
lovetoxhas joined
suohuahas joined
florettahas left
Guushas joined
sonnyhas left
sonnyhas joined
suohuahas left
lovetoxhas left
lovetoxhas joined
SouLhas left
SouLhas joined
SJMhas joined
paulhas left
Wojtekhas joined
alex-a-sotohas left
alex-a-sotohas joined
debaclehas joined
Zashhas left
Zashhas joined
florettahas joined
asterixhas left
asterixhas joined
Sam Whited
Does xmpp.js have literally no documentation except a readme with an example or two in some of the repos?
COM8has joined
COM8has left
Sam Whited
Daniel: this.Transport seems to have a Socket in it that I assume is a net.Socket which you can call setTimeout on https://nodejs.org/docs/latest-v15.x/api/net.html#net_socket_settimeout_timeout_callback
Sam Whited
No idea if that's ever exposed in an easier way though, I couldn't find a timeout option or anything
Sam Whited
The reconnect stuff has a timeout too, but again, no docs on how to set it that I can find.
Daniel
yes xmpp.js isn’t exaclty well documented. but from a quick research it is the only java script xmpp library that can do tcp
Daniel
yes i've started to suspect that the problem i ran into was actually the reconnect timeout. not the socket time out
sonnyhas left
sonnyhas joined
COM8has joined
flow
sonny, ↑
Neustradamushas left
pasdesushihas joined
Neustradamushas joined
fade123has left
asterixhas left
asterixhas joined
suohuahas joined
Sam Whited
What's a good name for a package that's only purpose is to be used internally by devs to create other packages. Eg. lots of packages have something that sends and IQ, unmarshals the response into a value, etc. so this package would have the generic "SendIQ" logic that does all that, handles errors, etc. so that you don't have to rewrite it every time.
COM8has left
Sam Whited
But I can't for the life of me think of a package name that conveys "internal functions for contributors to make implementing XEPs easier"
jonas’
to me, sendIQ sounds like something which shouldn’t be a separate package but just part of the core api
Sam Whited
The core API does have that it just doesn't do all this extra stuff.
defanor
I think those usually go into something like "util" or "common", if it has to be generic.
Sam Whited
defanor: those don't really convey the intent, I generally think if you've created a package called "util" it's code smell and is just going to become an unmanageable dumping ground for random functions that should have been put somewhere else.
Sam Whited
Then again, maybe that's what that specific example function is.
Sam Whited
Yah, maybe if I'm having such trouble thinking of a name and defining what this package is for it's the same thing and I should think of somewhere else for this shared logic to go. I dunno, I'm struggling with this.
Sam Whited
Or maybe this particular example really should be core functionality even though it's sort of higher level than everything else. I just hate to add more IQ related methods to the session type which already has the confusingly named EncodeIQ, EncodeIQElement, SendIQ, and SendIQElement (which all do more or less the same thing with minor differences)
Wojtekhas left
Wojtekhas joined
Wojtekhas left
paulhas joined
suohuahas left
Sam Whited
jonas’: thinking about it more, you're absolutely right. This will be useful to more than just package authors and should be on the core session stuff.
Sam Whited
So I guess the question becomes "What should those methods be called?" I can never think what conveys the intent. "MarshalIQ" maybe? "MarshalAndDecodeIQ" is a bit long. I dunno.
Sam Whited
"RoundtripIQ"?
Zash
What does it do? Send an iq and return the response?
Sam Whited
More or less (as opposed to the existing SendIQ and EncodeIQ functions which just return the XML stream, this returns an actual concrete type that the user specified or an error representing the IQ error)
Zash
I think this is called SendIQ or similar in all libraries I've seen.
sonny
Daniel, setting a TCP timeout is not exposed publicaly but I'd be happy to implement that for you - meanwhile I can give you a workaround if you like
Sam Whited
Zash: SendIQ is already a thing, unfortunately. This is "HigherLevelSendIQ" :)
Zash
Naming things!
Zash
`await QueryResponse(SendIQ(···))` 🤷
Sam Whited
Maybe this is too high level for the main library. Eg. the http library doesn't unmarshal JSON for you, it just returns the body and you get to interpret it how you want. But then I'm back to not knowing where to put this.
sonny
Daniel, the documentation for reconnect is here https://github.com/xmppjs/xmpp.js/tree/master/packages/reconnect
Daniel
just so i understand. delay != timeout?
Daniel
so if i'm seeing a timeout error on connect it's probably the socket?
sonny
can you share the exact error?
sonny
(sounds like it yes)
Wojtekhas joined
sonny
not sure what the problem exactly is but you could try changing client.timeout - the default is 2000 (ms) which is probably too low
suohuahas joined
Daniel
sonny, what's that timeout being used for?
sonny
if you get a TimeoutError on `.start()` then that's the culprit✎
sonny
if you get a `TimeoutError` on `.start()` then that's the culprit ✏
sonny
please open an issue with more details - it will be easier to figure out what the issue is and find out what needs to be documented✎
sonny
please open an issue with more details - it will be easier to figure out what the issue is and find out what needs to be documented or changed ✏
lovetox_has joined
lovetox_has left
mikeyehas joined
kikuchiyohas left
fade123has joined
kikuchiyohas joined
lovetox_has joined
marmistrzhas left
jubalhhas joined
jubalhhas left
mikeyehas left
Danielhas left
Danielhas joined
Danielhas left
Danielhas joined
marmistrzhas joined
marmistrzhas left
marmistrzhas joined
paulhas left
jubalhhas joined
Sam Whited
Mocked it up and called it "MarshalIQ, MarshalIQElement, IterIQ, and IterIQElement"… that's a lot of new methods and it still feels wrong and confusingly named somehow (the extra "Iter" methods don't matter, I just realized that I'd need them too because a few things like roster fetches work differently and iterate over the children instead of just returning them all in one go like most IQs do)