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

Update (or relax) dependencies #236

Closed
thiagomajesk opened this issue Apr 4, 2021 · 5 comments · Fixed by #240
Closed

Update (or relax) dependencies #236

thiagomajesk opened this issue Apr 4, 2021 · 5 comments · Fixed by #240
Assignees

Comments

@thiagomajesk
Copy link

thiagomajesk commented Apr 4, 2021

Hello everyone! Just tried the lib today by creating a brand new Phoenix app and I got the following error:

Failed to use "cowlib" (version 2.9.1) because
  cowboy (version 2.8.0) requires ~> 2.9.1
  gun (versions 1.3.0 to 1.3.2) requires ~> 2.6.0
  mix.lock specifies 2.9.1


Failed to use "cowlib" (version 2.9.1) because
  cowboy (version 2.8.0) requires ~> 2.9.1
  gun (version 1.3.3) requires ~> 2.7.0
  mix.lock specifies 2.9.1

Do you think we could have this updated?

PS.: Out of curiosity: Is the gun lib really necessary if using httpoison?

@Kraigie
Copy link
Owner

Kraigie commented Apr 4, 2021

You can override the dependencies if you wanted, but I agree that they should be updated.

Also, we use gun as a websocket client. I think the better question is why we httpoison when we use gun. I think they fulfill different enough roles to both be useful.

@thiagomajesk
Copy link
Author

Hi @Kraigie! Thanks for the reply...

I've tried {:nostrum, "~> 0.4", override: true} and {:plug_cowboy, "~> 2.0", override: true} before posting (for test sake), but I got the same error, any suggestions?

Also, we use gun as a websocket client. I think the better question is why we httpoison when we use gun. I think they fulfill different enough roles to both be useful.

I was curious because I thought that httpoison could handle WebSockets too. Thanks for the response though.

@Kraigie
Copy link
Owner

Kraigie commented Apr 4, 2021

I've tried {:nostrum, "> 0.4", override: true} and {:plug_cowboy, "> 2.0", override: true} before posting (for test sake), but I got the same error, any suggestions?

I think you might need to override gun, but I never remember these things. Regardless it'll be updated soon!

I was curious because I thought that httpoison could handle WebSockets too. Thanks for the response though.

It's an HTTP library so we probably could have it handle websockets, but gun was built in a way that makes it very easy to integrate with.

@thiagomajesk
Copy link
Author

thiagomajesk commented Apr 4, 2021

I think you might need to override gun, but I never remember these things.

Yes, of course! I was already trying to figure out if I ever manage to override an "indirect" dependency of some project 😆.
I manage to compile with gun's master, but also overriding cowlib since they're requiring cowlib 1.10 for the new rc's:

 {:gun, github: "ninenines/gun", override: true},
 {:cowlib, "~> 2.10", override: true}

At least it's compiling now! 🙏

Regardless it'll be updated soon!

Sorry to bother you, but do you have any ETA to share?

It's an HTTP library so we probably could have it handle websockets, but gun was built in a way that makes it very easy to integrate with.

Interesting, I haven't heard about gun before, but I'll certainly take a look at it. Thanks for the clarification.

Update: Well I didn't have any luck, since the latest version (that requires a more recent version of cowlib) also has a different API:

[error] GenServer #PID<0.799.0> terminating
** (UndefinedFunctionError) function :gun.ws_send/2 is undefined or private
    (gun 2.0.0-rc.1) :gun.ws_send(#PID<0.802.0>, {:binary, <<131, 116, 0, 0, 0, 2, 109, 0, 0, 0, 1, 100, 116, 0, 0, 0, 6, 109, 0, 0, 0, 8, 99, 111, 109, 112, 114, 101, 115, 115, 100, 0, 5, 102, 97, 108, 115, 101, 109, 0, 0, 0, 7, 105, 110, 116, 101, 110, ...>>})
    (nostrum 0.4.6) lib/nostrum/shard/session.ex:118: Nostrum.Shard.Session.handle_info/2
    (stdlib 3.13) gen_server.erl:680: :gen_server.try_dispatch/4
    (stdlib 3.13) gen_server.erl:756: :gen_server.handle_msg/6
    (stdlib 3.13) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
Last message: {:gun_ws, #PID<0.802.0>, #Reference<0.1336532227.624951298.13045>, {:binary, <<120, 156, 106, 46, 97, 96, 96, 96, 73, 97, 96, 76, 1, 49, 152, 82, 24, 216, 226, 75, 138, 18, 147, 83, 115, 128, 60, 198, 92, 32, 161, 17, 173, 148, 158, 88, 146, 90, 158, 88, 169, 91, 80, 148, ...>>}}
State: %Nostrum.Struct.WSState{conn: #PID<0.802.0>, conn_pid: #PID<0.799.0>, gateway: "gateway.discord.gg/?compress=zlib-stream&encoding=etf&v=6", heartbeat_ack: true, heartbeat_interval: nil, heartbeat_ref: nil, last_heartbeat_ack: ~U[2021-04-04 03:05:49.581946Z], last_heartbeat_send: nil, seq: nil, session: nil, shard_num: 0, shard_pid: nil, zlib_ctx: #Reference<0.1336532227.625082370.13050>}

I guess I'll have to wait then 🤷‍♂️.

@jchristgit jchristgit self-assigned this May 18, 2021
jchristgit added a commit that referenced this issue May 18, 2021
This prevents dependency problems when trying to use nostrum with e.g. Phoenix,
as outlined in #236. It also sets the foundation for using `:gun` as our one
and only HTTP client, instead of relying on an extra library here.

Fixes #236.
jchristgit added a commit that referenced this issue May 18, 2021
This prevents dependency problems when trying to use nostrum with e.g. Phoenix,
as outlined in #236. It also sets the foundation for using `:gun` as our one
and only HTTP client, instead of relying on an extra library here.

Fixes #236.
jchristgit added a commit that referenced this issue May 18, 2021
This prevents dependency problems when trying to use nostrum with e.g. Phoenix,
as outlined in #236. It also sets the foundation for using `:gun` as our one
and only HTTP client, instead of relying on an extra library here.

Fixes #236.
@thiagomajesk
Copy link
Author

I can confirm this fixed the problem for me. Thanks for the great work @jchristgit! Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants