webrtc / apprtc

appr.tc has been shutdown. Please use the Dockerfile to run your own test/dev instance.
BSD 3-Clause "New" or "Revised" License
4.16k stars 1.37k forks source link

Non-200 response when requesting TURN server from https://networktraversal.googleapis.com/v1alpha/iceconfig?key=none : HTTP/ 1.1 Bad Requst #394

Closed KasusKnaxus closed 7 years ago

KasusKnaxus commented 7 years ago

Hello guys,

Description Since I few weeks I'm trying to establish a connection between a native android app (e.g. njovy) and a browser by using apprtc. The app works perfectly when using appr.tc as server. Additionally I'm able to create a conference between two browser-clients e.g. browser of my laptop and browser of my mobile device. The following issue occurs on my mobile when I try to establish a connection between a browser client and the app:

Room IO error: java.io.IOException: Non-200 response when requesting TURN server from https:// networktraversal.googleapis.com/ v1alpha/iceconfig?key=none : HTTP/ 1.1 400 Bad Request

error

GAE regocnizes that there is a new request coming from the app. The first one is the browser-client, the 2nd one the app:

INFO     2016-11-05 00:06:31,649 apprtc.py:408] Added client 50600142 in room stackoverflow, retries = 0
INFO     2016-11-05 00:06:31,650 apprtc.py:92] Applying media constraints: {'video': True, 'audio': True}
WARNING  2016-11-05 00:06:31,653 apprtc.py:136] Invalid or no value returned from memcache, using fallback: null
INFO     2016-11-05 00:06:31,653 apprtc.py:551] User 50600142 joined room stackoverflow
INFO     2016-11-05 00:06:31,653 apprtc.py:552] Room stackoverflow has state ['50600142']
INFO     2016-11-05 00:06:31,658 module.py:788] default: "POST /join/stackoverflow?wstls=false HTTP/1.1" 200 1175

Steps to reproduce

After that I changed the requestIceServers in util.js

// Returns a list of ICE servers after requesting it from the ICE server
// provider.
// Example response (iceServerRequestResponse) from the ICE server provider
// containing two TURN servers and one STUN server:
// {
//   lifetimeDuration: '43200.000s',
//   iceServers: [
//     {
//       urls: ['turn:1.2.3.4:19305', 'turn:1.2.3.5:19305'],
//       username: 'username',
//       credential: 'credential'
//     },
//     {
//       urls: ['stun:stun.example.com:19302']
//     }
//   ]
// }

/* --> Changes commented out as requested in deployment
function requestIceServers(iceServerRequestUrl, iceTransports) {
  return new Promise(function(resolve, reject) {
    sendAsyncUrlRequest('POST', iceServerRequestUrl).then(function(response) {
      var iceServerRequestResponse = parseJSON(response);
      if (!iceServerRequestResponse) {
        reject(Error('Error parsing response JSON: ' + response));
        return;
      }
      if (iceTransports !== '') {
        filterIceServersUrls(iceServerRequestResponse, iceTransports);
      }
      trace('Retrieved ICE server information.');
      resolve(iceServerRequestResponse.iceServers);
    }).catch(function(error) {
      reject(Error('ICE server request error: ' + error.message));
      return;
    });
  });
}*/

// --> Changes inserted as requested in deployment
function requestIceServers(iceServerRequestUrl, iceTransports) {
  return new Promise(function(resolve, reject) {
    var servers = [{
        credential: "diveinedu",
        username: "diveinedu",
        urls: [
          "turn:192.168.178.20:3478?transport=udp",
          "turn:192.168.178.20:3478?transport=tcp"
        ]
    }];
    resolve(servers);
  });
}

Some tips I found by doing reseach - but these didn't do the trick:

Thanks in advance

KaptenJansson commented 7 years ago

I'm currently working on improving the instructions to make this easier but have not had a chance to finish them yet.

You should only need to change to the TURN_SERVER_OVERRIDE and WSS_INSTANCE_HOST_KEY constants, leave the TURN_BASE_URL as is and do not change any other code in AppRTC:

dudhatparesh commented 7 years ago

I am also facing same issue guys? Any solution.

KaptenJansson commented 7 years ago

Please take a look at the updated instructions and let me know if the issue persists.

rootmonty commented 7 years ago

Hi, I have gone through the above discussion and stll facing some ambiguities. Right now I am facing this error while connecting my client android device to locally hosted server I think its probably because of the TURN navigation but am not sure.Can you please help me out of this. The following is the error I get displayed in the alert dialog box once I try to connect to my server for the conference call

E/RoomRTCClient:Room connection error: HTTP POST to http://localhost:8080/r/alphapronto error: failed to connect to localhost/127.0.0.1 (port 8080) after 8000ms: isConnected failed: ECONNREFUSED (Connection refused) E/WSRTCClient: HTTP POST to http://localhost:8080/r/alphapronto error: failed to connect to localhost/127.0.0.1 (port 8080) after 8000ms: isConnected failed: ECONNREFUSED (Connection refused)

shantanubanerjee commented 7 years ago

I am tying to setup the local server instead of appr.tc for webrtc audio/video conferencing.

I have got the same error as posted https://github.com/webrtc/apprtc/issues/394

Room IO error: java.io.IOException: Non-200 response when requesting TURN server from https:// networktraversal.googleapis.com/ v1alpha/iceconfig?key=none : HTTP/ 1.1 400 Bad Request

My constant.py file contains and Collider and Coturn is installed

TURN_BASE_URL = 'https://computeengineondemand.appspot.com' TURN_URL_TEMPLATE = '%s/turn?username=%s&key=%s' CEOD_KEY = '4080218913'

TURN_BASE_URL = 'http://192.168.0.5:8080'

TURN_URL_TEMPLATE = '%s/turn.php?username=%s&key=%s'

CEOD_KEY = 'test'

ICE_SERVER_BASE_URL = 'https://networktraversal.googleapis.com' ICE_SERVER_URL_TEMPLATE = '%s/v1alpha/iceconfig?key=%s' ICE_SERVER_API_KEY = os.environ.get('ICE_SERVER_API_KEY')

Sorry I am not able to understand the below steps in Github

Else if using ICE Server provider [1]
    Change ICE_SERVER_BASE_URL to your ICE server provider host.
    Change ICE_SERVER_URL_TEMPLATE to a path or empty string depending if your ICE server provider has a specific URL path or not.
    Change ICE_SERVER_API_KEY to an API key or empty string depending if your ICE server provider requires an API key to access it or not.

ICE_SERVER_BASE_URL = 'https://networktraversal.googleapis.com'
ICE_SERVER_URL_TEMPLATE = '%s/v1alpha/iceconfig?key=%s'
ICE_SERVER_API_KEY = os.environ.get('ICE_SERVER_API_KEY')

Is there anything wrong with ICE server configuration?

KaptenJansson commented 7 years ago

Please read the text more carefully, you are not using an ICE server provider, you are using a turn server directly (coturn is a turn server, not an ICE server provider (a web server returning TURN/STUN server URL's and credentials in a JSON response is an ICE server)).

Follow the If using TURN and STUN servers directly instructions.

NityaSoftwareSolutionsInc commented 7 years ago

Hi,

I am using own turn server (resiprocate-turn-server) web and ios working. But android it is going same NON 200 response https;//networktranversal.com. How to solve this problem in android.

Thanks, Raviteja

vanann123 commented 6 years ago

when I run on Chrome is Ok. But run on Android was be error "Room IO error: java.io.IOException:Non-200 " Then I fix it by follow :

1 go to server soure at src\app_engine\apprtc.py then edit :

def make_pc_config(ice_transports): config = { 'iceServers': [{"credential":"mgDZ3AzyUXLDR7ahguE8LdM3ABU=","urls":["turn:64.233.188.127:19305?transport=udp","turn:[2404:6800:4008:c04::7f]:19305?transport=udp","turn:64.233.188.127:443?transport=tcp","turn:[2404:6800:4008:c04::7f]:443?transport=tcp"],"username":"CI6C9s8FEgazBnJX1zcYzc/s6OMTIICjBQ"},{"urls":["stun:stun.l.google.com:19302"]}], 'bundlePolicy': 'max-bundle', 'rtcpMuxPolicy': 'require' }; if ice_transports: config['iceTransports'] = ice_transports return config

2 I go to code client :

RoomParametersFetcher.java ==> go to iceServersFromPCConfigJSON method and edit :

private LinkedList iceServersFromPCConfigJSON(String pcConfig) throws JSONException { JSONObject json = new JSONObject(pcConfig); JSONArray servers = json.getJSONArray("iceServers"); LinkedList ret = new LinkedList(); for (int i = 0; i < servers.length();i++) { JSONObject server = servers.getJSONObject(i); JSONArray urls = server.getJSONArray("urls"); String credential = server.has("credential") ? server.getString("credential") : ""; String username = server.has("username") ? server.getString("username") : ""; String url ; for (int k = 0; k < urls.length(); k++) { url = urls.getString(k); if(url != "") { ret.add(new PeerConnection.IceServer(url, username, credential)); } } } return ret; }

coderxhs commented 6 years ago

Hi KaptenJansson: I also met this problem, i am using coturn followed https://github.com/coturn/coturn, web works well, but android demo going to the same Exception, @KaptenJansson is there any effective solution to fix this on Android? thanks!

zengpeace commented 5 years ago

I meet this problem too, but i found a way to fix it, I hope it can help everyone. do not modify the code of server, just modify the code of client. In android demo code, a file names RoomParametersFetcher.java, find out and delete this line in it: "connection.setDoOutput(true);"

razakhan22 commented 2 years ago

Hello @KasusKnaxus i need your help please help me. Please say hii on my gmail. rk5387042@gmail.com we will talk there