meetecho / janus-gateway

Janus WebRTC Server
https://janus.conf.meetecho.com
GNU General Public License v3.0
8.17k stars 2.47k forks source link

Might have a problem with WS api #1124

Closed ghost closed 6 years ago

ghost commented 6 years ago

After sending {\"janus\":\"create\",\"transaction\":\"qw5DX/TImxNaWBe02xpZ\"} to janus it logs the following

...
[Wed Jan  3 20:49:46 2018] [WSS-0x7fdf9d812c00] Got 55 bytes:
[Wed Jan  3 20:49:46 2018] [WSS-0x7fdf9d812c00] First fragment: 55 bytes, 0 remaining
[Wed Jan  3 20:49:46 2018] {"janus":"create","transaction":"qw5DX/TImxNaWBe02xpZ"}
[Wed Jan  3 20:49:46 2018] [WSS-0x7fdf9d812c00] Done, parsing message: 55 bytes
[Wed Jan  3 20:49:46 2018] Got a Janus API request from janus.transport.websockets (0x7fdf9d50fef0)
[Wed Jan  3 20:49:46 2018] Transport task pool, serving request
[Wed Jan  3 20:49:46 2018] Creating new session: 4485517464138841
[Wed Jan  3 20:49:46 2018] Sending Janus API response to janus.transport.websockets (0x7fdf9d50fef0)
...

but never sends the created session id back.

However, if I send several similar requests (about 100), it does. And logs the following lines in addition for each of them

...
[Wed Jan  3 20:53:11 2018] [WSS-0x7fdf9d812c00] Sending WebSocket message (115 bytes)...
[Wed Jan  3 20:53:11 2018] [WSS-0x7fdf9d812c00]   -- Sent 115/115 bytes
...

I'm on mac and installed libwebsockets from brew.

> brew info libwebsockets
libwebsockets: stable 2.4.1 (bottled), HEAD
C websockets server library
https://libwebsockets.org
/usr/local/Cellar/libwebsockets/2.4.1_1 (21 files, 751.2KB) *
  Poured from bottle on 2018-01-02 at 13:51:18
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/libwebsockets.rb
==> Dependencies
Build: cmake ✔
Required: libev ✔, libuv ✔, libevent ✔, openssl ✔

Janus commit: 345641443fa073b4274cf6eabe5b190077629cce

ghost commented 6 years ago

I think I should try running janus in a docker container to make sure it's not just a mac issue.

lminiero commented 6 years ago

Well known issue with libwebsockets on mac, you need master of that library as they only fixed it recently there. Closing.

MinorUncle commented 6 years ago

This problem is solved? Why do I have the same problem with all three Macos, Is it wrong with me?

My libwebsocket version is v2.4.1_1, srtp version is v2.1.0, Libnice is v0.1.14, Openssl is v1.0.2o,

ghost commented 6 years ago

@MinorUncle

libwebsocket version is v2.4.1_1

I think this version is still affected. According to my post above, I used the same version.

I see there is a newer version on brew, maybe you could try it and tell us if it worked?

> brew info libwebsockets
libwebsockets: stable 2.4.2 (bottled), HEAD
...

As for me, I found it easier to run janus in a docker container while developing for it. Since I run it on a linux box in "production" anyway.

MinorUncle commented 6 years ago

Hi @idi-ot I switched to v2.4.2, libwebsockets: stable 2.4.2 (bottled), HEAD But the result was the same error, I'm debugging it with Xcode, so I still can't put it in docker.

ghost commented 6 years ago

I'm debugging it with Xcode, so I still can't put it in docker.

Are you running janus as part of your XCode project? If you could explain what exactly you are trying to accomplish with janus on macos, it would be easier for us to help you.

If 2.4.2 doesn't work, maybe try building from source.

MinorUncle commented 6 years ago

Yes, but there's a error with this WS

ghost commented 6 years ago

Yes, you are running janus as part of your XCode project? Or yes, you tried building from source and it didn't work?

I think of Janus as primarily "server-side" software, and there are not many servers running on macos, so what exactly are you using janus for?

MinorUncle commented 6 years ago

Sorry, English is not my native language, so I answer slowly and even make some mistakes.

MinorUncle commented 6 years ago

Yes, I am running janus as part of my XCode project

ghost commented 6 years ago

Are you developing a macos app with janus as an embedded webrtc server? Or are you developing an app which acts as a webrtc client and interacts with a remote janus instance?

MinorUncle commented 6 years ago

But when I ran it through Xcode, it appeared the same error as you.

MinorUncle commented 6 years ago

NO,only janus-gateway server

ghost commented 6 years ago

Then the easiest way would be to compile the dependencies from source in your project's build phase or whatever it's called in XCode, I think.

MinorUncle commented 6 years ago

I tried building the libwebsockets v2.4.2 from source with XCode,and the result was the same problem.

MinorUncle commented 6 years ago

I try to compile Janus on Xcode, just for debugging easily.

MinorUncle commented 6 years ago

I just debugged and found that janus_websockets_common_callback was not invoked, resulting in lws_write not being invoked. I will continue tracing the source code tomorrow.

xcolwell commented 6 years ago

I'm seeing this same behavior with the latest master of libwebsockets and janus. Did you find a resolution?

xinxi053 commented 5 years ago

libwebsockets: stable 3.1.0 (bottled) still no websocket response.

xinxi053 commented 5 years ago

Finally, when i downgrade to 3.0.0 stable, and compile manually, it works! https://github.com/warmcat/libwebsockets/blob/v3.0-stable/READMEs/README.build.md