Code Monkey home page Code Monkey logo

samples-server's Introduction

samples-server

Notice

The MDN samples-server service at https://mdn-samples.mozilla.org/ (https://github.com/mdn/samples-server) has been shut down for security reasons. The existing examples will of course stop working until they can be replaced with something better, and although we're sorry for the inconvenience, we felt the inconvenience was outweighed by the security vulnerability.

See also

Original README

This is a live sample server for MDN, which I hope we will be able to use to host content that only works when on a less restrictive environment than running in an iframe on Kuma.

The ''s'' directory contains a folder for each project that needs to be available. Each one has a manifest and whatever files that service requires.

The ''v'' directory is a place we can keep miscellaneous assets which may be needed by MDN content, can't be attached to MDN pages, and have no other home.

samples-server's People

Contributors

a2sheppy avatar chrisdavidmills avatar escattone avatar limed avatar mdahshan avatar rubenhorn avatar teoli2003 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

samples-server's Issues

getUserMedia error: NotReadableError

Demo working on Google Chrome Version 58.0.3029.110 (64-bit) On Window 10( 64-bit)
But not working on Firefox 54.0 (32-bit)
i write you code with MediaDevices.getUserMedia()

`

// Older browsers might not implement mediaDevices at all, so we set an empty object first
if (navigator.mediaDevices === undefined) {
navigator.mediaDevices = {};
}

	// Some browsers partially implement mediaDevices. We can't just assign an object
	// with getUserMedia as it would overwrite existing properties.
	// Here, we will just add the getUserMedia property if it's missing.
	if (navigator.mediaDevices.getUserMedia === undefined) {
		navigator.mediaDevices.getUserMedia = function(constraints) {
			
			// First get ahold of the legacy getUserMedia, if present
			var getUserMedia = navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
			
			// Some browsers just don't implement it - return a rejected promise with an error
			// to keep a consistent interface
			if (!getUserMedia) {
				return Promise.reject(new Error('getUserMedia is not implemented in this browser'));
			}
			
			// Otherwise, wrap the call to the old navigator.getUserMedia with a Promise
			return new Promise(function(resolve, reject) {
				getUserMedia.call(navigator, constraints, resolve, reject);
			});
		}
	}

	
	navigator.mediaDevices.getUserMedia({ audio: false, video: true })
	
	.then(function(stream) {
		var video = document.querySelector('video');
		// Older browsers may not have srcObject
		if ("srcObject" in video) {
			video.srcObject = stream;
			} else {
			// Avoid using this in new browsers, as it is going away.
			video.src = window.URL.createObjectURL(stream);
		}
		video.onloadedmetadata = function(e) {
			video.play();
		};
	})
	.catch(function(err) {
		//console.log(err.name + ": " + err.message);
		console.log('Error');
	});

`

still not working on Firefox...
.catch runs... and show error msg "Error" in console.
But Chrome still working....

MediaDevices

CODE_OF_CONDUCT.md isn't correct

Your required text does not appear to be correct

As of January 1 2019, Mozilla requires that all GitHub projects include this CODE_OF_CONDUCT.md file in the project root. The file has two parts:

  1. Required Text - All text under the headings Community Participation Guidelines and How to Report, are required, and should not be altered.
  2. Optional Text - The Project Specific Etiquette heading provides a space to speak more specifically about ways people can work effectively and inclusively together. Some examples of those can be found on the Firefox Debugger project, and Common Voice. (The optional part is commented out in the raw template file, and will not be visible until you modify and uncomment that part.)

If you have any questions about this file, or Code of Conduct policies and procedures, please reach out to [email protected].

(Message COC003)

webrtc: addTransceiver: demo doesn't work when trying to bypass trickle ICE

Previously with addTrack it was possible to bypass trickle ICE.

  1. Disable sending new-ice-candidate or immediately sending video-offer/video-answer
  2. Wait until ICE gathering is complete event.candidate === null; then send video-offer/video-answer; in this case the SDP is fully populated with ICE candidates.

With addTransaction, this no longer works.

webrtc-from-chat potential XSS vulnerability, unfiltered data.

I was able to corrupt the user list for all users using the following script:

setInterval(function() {sendToServer({type:"userlist",users:["Hacked.","By helllo-smile6@github"]});,1);

Additionally, HTML entities can be used in the chat. HTML code is nullified. This may create additional, more secure vulnerabilities.

Missing Script?

I was looking through the webRTC examples to see if I could use one as a template, and upon looking at webrtc-simple-datachannel/index.html there is a script mentioned called ../adapter.js. Looks like it's missing.

Is it not needed? What is it for?

i have httpurlconnection problem

I try to Send POST request chatserver using android app, but chatserver didn't accept
I thought that chat server get request and it response 200

this is chatserver.js code which I changed

-------------------------------chatserver.js--------------------------------------------
var httpsServer = https.createServer(httpsOptions, function(request, response) {
var file = http_files[request.url];
if (file) {
response.writeHeader(200,{"content-type" : file.contentType});
response.write(file.content);
return response.end();
} else{
log("Received secure request for " + request.url);
response.writeHead(404);
response.end();
}
});

// Spin up the HTTPS server on the port assigned to this sample.
// This will be turned into a WebSocket port very shortly.

httpsServer.listen(6503, function() {
log("Server is listening on port 6503");
});

// Create the WebSocket server by converting the HTTPS server into one.

var wsServer = new WebSocketServer({
httpServer: httpsServer,
autoAcceptConnections: false
});

// Set up a "connect" message handler on our WebSocket server. This is
// called whenever a user connects to the server's port using the
// WebSocket protocol.

wsServer.on('request', function(request) {
if (!originIsAllowed(request.origin)) {
request.reject();
log("Connection from " + request.origin + " rejected.");
return;
}

// Accept the request and get a connection.

var connection = request.accept("json", request.origin);

// Add the new connection to our list of connections.

log("Connection accepted from " + connection.remoteAddress + ".");
connectionArray.push(connection);

connection.clientID = nextID;
nextID++;
--------------------------------chatserver.js-------------------------------------------

and this is android app code which responseCode are always response 404

-------------------------------android app----------------------------------------------
//app Send POST request.
if (doOutput && postData.length > 0) {
OutputStream outStream = connection.getOutputStream();
outStream.write(postData);
outStream.close();
}

//app Get response.
int responseCode = connection.getResponseCode();
if (responseCode != 200) {
events.onHttpError("Non-200 response to " + method + " to URL: " + url + " : "
+ connection.getHeaderField(null));
connection.disconnect();
return;
}
-----------------------------------android app---------------------------------------

Update Apache / SSH Config

Mozilla infosec noticed that the MDN Code Samples service is running a vulnerable version of Apache (2.4.6) and an SSH config that's a little outside of what our suggested configuration is.
https://www.shodan.io/host/52.0.70.144

From talking with @a2sheppy, it sounds like the instance automatically updates when it's rebooted, so it's likely that a reboot will bring Apache up to date. For the SSH config, we recommend the "Modern" configuration file specified in our suggested configuration guide.

If you need any help or assistance getting this instance cleaned up, don't hesitate to let me know and I'll make sure you get whatever resources you need!

https://github.com/mdn/samples-server
AWS Account: cloudservices-aws-dev
InstanceID: i-42a595fc

What is the hostname for turns server?will it be chat servers address or we need to setup stun/turn server(or use default one eg: stun:stun.l.google.com:19302)

 myPeerConnection = new RTCPeerConnection({
    iceServers: [     // Information about ICE servers - Use your own!
      {
        urls: "turn:" + myHostname,  // A TURN server
        username: "webrtc",
        credential: "turnserver"
      }
    ]
  });

myHostname refers to chat server host url or we need to setup our own turn server(or can we use default stun server eg: eg: stun:stun.l.google.com:19302 )?And if use the this same process using react-native-webrtc will it work (i need this for react-native app)?

how to deploy webrtc-capturestill

Hi all, thank you for the contribution.
I am new to Javascript and HTML, but now I need to do a demo with webrtc to capture the image with browser, your webrtc-capturestill is just what I need, but I dont know how to deploy it and cannot find any document, can you give me some hints on it, thank you
I just want to setup the demo like this one:
https://mdn-samples.mozilla.org/s/webrtc-capturestill/
do I need to install a webserver? my OS is ubuntu 18.04

DOMException: Failed to execute 'setLocalDescription' on 'RTCPeerConnection': Called in wrong signalingState: kStable

I just test the webrtc demo on https://webrtc-from-chat.glitch.me/
I found it works well when firefox calls firefox,chrome calls chrome and firefox calls chrome, but fails when chrome calls firefox. The last logs in chrome console as below:

[1:39:13 PM] *** Adding received ICE candidate: {"candidate":"candidate:0 2 UDP 2122252542 192.168.2.101 59175 typ host","sdpMid":"1","sdpMLineIndex":1}
client.js:56 [1:39:13 PM] Message received:
client.js:128 Object
client.js:56 [1:39:13 PM] *** Adding received ICE candidate: {"candidate":"candidate:3 2 TCP 2105524478 192.168.2.101 9 typ host tcptype active","sdpMid":"1","sdpMLineIndex":1}
client.js:56 [1:39:13 PM] *** ICE connection state changed to connected
client.js:56 [1:39:13 PM] *** WebRTC signaling state changed to: stable
2client.js:56 [1:39:13 PM] *** Track event
client.js:56 [1:39:13 PM] *** WebRTC signaling state changed to: have-remote-offer
client.js:56 [1:39:13 PM] *** ICE gathering state changed to: complete
client.js:56 [1:39:13 PM] *** ICE gathering state changed to: gathering
client.js:605 Uncaught (in promise) DOMException: Failed to execute 'setLocalDescription' on 'RTCPeerConnection': Called in wrong signalingState: kStable

onnegotiationneeded event fired twice in Chrome

sample tested in Chrome 68 - doesn't work
without adapter:

Failed to set remote offer sdp: Called in wrong state: kHaveLocalOffer

with adapter:

PeerConnection cannot create an answer in a state other than have-remote-offer or have-local-pranswer.

but in FF works just fine.

I've figured out that Chrome fires onnegotiationneeded on each track added while FF fires it once. Firing twice results into sending offer twice

How to workaround that issue, does anybody knows?

how to run it

i'm new to this code, can anyone help me with the flow (i.e. how to run it). i have installed npm for running index file but it was just a guess. a little help will be appreciated.

Video streaming had not play

I follow Blog but when i compile my project , no error. Everything fine but video streaming is not playing.

Webrtc-Code. Please help me to resolve this error
OS : linux amd64
browser : chrome

webrtc-from-chat: addTransceiver: causes an extra video-offer/video-answer from callee

The updated signalling in webrtc-from-chat (specifically addTrack -> addTransceiver) causes onnegotiationneeded to be fired on the callee and another round-trip of video-offer/video-answer.

Is this behaviour expected and correct?

It seems expensive to require another round of video-offer/video-answer. Replacing addTransceiver with addTrack restores the old behaviour.

The difference is in the Answer SDP:

  • addTrack puts a=sendrecv
  • addTransceiver puts a=recvonly

Presumably a=recvonly is the reason why the callee initiates the video-offer round-trip. I have seen recvonly mentioned in the posts on Advancing WebRTC; is this behaviour mandatory now?

Old signalling (addTrack)
caller: sends video-offer
callee: sends video-answer
=== call is connected ===

New signalling (addTransceiver)
caller: sends video-offer
callee: sends video-answer (call not connected yet)
callee: onnegotiationneeded is fired
callee: sends video-offer
caller: sends video-answer
=== call is connected ===

Sample site expired https certificate

Hello,

I'm aware this isn't strictly an issue with the code, but the security certificate for the sample site expired yesterday (23 October) (so we get a 'NET::ERR_CERT_DATE_INVALID' error).

Thanks
Lee

Bugs

  1. First of all the text chat does not work properly, most of the time you just lose the ability to post anything or receive any new messages.
  2. In all the cases (pc and phone Mozilla, Google ) when I was able to establish proper text chat connection and make a call finally, it was never possible to get the remote-end stream (both video and audio) signal on the side of the caller.
    You did a great job explaining the technology, and your article is great, and comprehensive, wish your demo would work.

Error when testing sample project

Error when testing sample project:

DOMException: play() failed because the user didn't interact with the document first. https://goo.gl/xX8pDD

On line 45 of the js.

I am getting this error when testing you sample project here. Is anyone else seeing this issue?

Thanks

Not working for windows to mac

Hello,

First of thank you very much for providing this wonderful demo.
I'm going to implement video call using webrtc with the help of this demo.
It works well but for some scenarios it doesn't work for me.

It will be glad if following scenarios where not working could be solved.
Windows - Windows : Working
Windows - Mac : Not Working

I'm using chrome browser in both windows and mac for this demo.

Thank you

Run webrtc-from-chat on hosting

first of all i run it project on my local machine (macOS) it's work ass well, no problem.

But when i install on my web hosting from cPanel i create node.js app, upload project, install modules and run project as

node chatserver.js

terminall risponde Server is listening on port 35000 (yes i changed port on chatserver.js & chatclient.js because on my hosting port 6503 is closed)

but when i go to my site load index.html and try to create new user, in console i see this problem

Connecting to server: wss://mysite.com:35000
chatclient.js:111 WebSocket connection to 'wss://mysite.com:35000/' failed: 
connect @ chatclient.js:111
onclick @ (index):37
chatclient.js:119 Event

Logs is clean
what i can control to resolve this?

How to attach remote video from another peer to <video> tag ?

We are not able to stream video to another peer , but able to see local video. Our hunch is that the remote stream coming from the other peer is not binding to the video element..
Thanks in advance.
function handleTrackEvent(event) { log("*** Track event"); document.getElementById("received_video").srcObject = event.streams[0]; document.getElementById("hangup-button").disabled = false; }

Mobile Safari 11 Unhandled Promise Rejection type error solved

createObjectURL is deprecated so in capture.js

//video.src = vendorURL.createObjectURL(stream);
video.srcObject = stream;

To prevent iOS full screen video and get around gesture requirement add attributes to video tag.
<video id="video" playsinline muted>Video stream not available.</video>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.