In 2.x, we used to have <subscriptionConnectionPar...
# apollo-kotlin
s
In 2.x, we used to have subscriptionConnectionParams and subscriptionTransportFactory. In 3.x we don’t. I’ve tried constructing my ApolloClient without replacing it with anything, thinking maybe the necessary headers will be added from the OkHttp interceptor instead which didn’t work. The docs show a setup like this, but maybe this doesn’t work when there’s authentication etc on the play. Tried instead going full out by using subscriptionNetworkTransport on the builder but this also brings the same issue. I feel like I am missing some big part of the puzzle here somehow. The exception is all referencing methods that are internal to flow or the apollo library so they don’t give me a lot of ideas on where to look next 🤔 The message says:
com.apollographql.apollo3.exception.SubscriptionOperationException: Operation error ChatMessage
where ChatMessage is a subscription. And I don’t quite know where to go from there, hence here I am if you have any obvious thing I am missing.
b
You probably need a connection payload. This doc shows how.
s
Hmm but in the “Alternatively…” section it adds that one can do it with the
subscriptionNetworkTransport
and
addHeader
approach which I have tried as well. Is it different than using
wsProtocol
and
connectionPayload
? Also good to note that this may be a good candidate to be added to the migration to 3.x docs since it’s not mentioned what one should use instead of subscriptionConnectionParams and subscriptionTransportFactory in the subscriptions section.
b
Yes, the 2 ways don't have the same effect and the one you need depends on the backend implementation. •
connectionPayload
will be sent along with the first message sent right after connecting (the
connection_init
message) •
addHeaders
will be used at a lower (http) level
s
Ahaaa, it does seem to not crash anymore now. This was very non-obvious to me, as I am not that well-versed in these low-level details. Thank you so much Benoit!
b
you're welcome! And good call about the migration guide, I'll have a look at adding this info.
s
Ah I just saw this, I just came here to say I opened this to help a bit. it’s a simple mention of the lack of
subscriptionConnectionParams
and a link on where to get this information. But I see you said you might look into this, if you wanted to write something more comprehensive feel free to reject the PR!
b
oh very nice! 🙏 No worries I didn't start anything on my side 🙂
nice and short, perfect 😄
s
I wondered about what you feel about relative references to other docs. I added
../advanced/authentication.mdx#authenticating-your-websockets
in there but doing a project-wide search I don’t see any other reference to “.mdx” so if you want a different approach I’d like to know for future reference as well 🤔
b
no I think that's all right
🙌 1