muaz-khan / WebRTC-Experiment

WebRTC, WebRTC and WebRTC. Everything here is all about WebRTC!!
https://www.webrtc-experiment.com/
MIT License
11.72k stars 3.95k forks source link

Uncaught Error: new Firebase failed #83

Open panchotiya opened 11 years ago

panchotiya commented 11 years ago

Hi... I get this error in the console Uncaught Error: new Firebase failed: First argument must be a valid firebase URL and the path can't contain ".", "#", "$", "[", or "]". How to solve this error please help me. Thanks in advance

muaz-khan commented 11 years ago

Can you share exact experiment link, please? Or otherwise the code you're trying.

Such issue occurs when we pass invalid character in the firebase URL; .e.g.

// look at this ------ /ABCDEF#$.[]
var firebase = new Firebase('https://chat.firebaseio.com/ABCDEF#$.[]');

To recover it; make sure you passed valid value in the constructors:

// it works
new RTCMultiConnection('valid-value');

// it fails
new RTCMultiConnection('invalid-value-#$[].');

// it works
new DataChannel('valid-value');

// it fails
new DataChannel('invalid-value-#$[].');

Whatever you pass over constructor is used in firebase URL. The thing you pass over constructor is known as channel or namespace.

stiofand commented 10 years ago

Actually this happens to me with a perfectly clean string to my firebase.io endpoint, its driving me crazy that there is no one addressing this issue in AngularFire

Atrix1987 commented 10 years ago

were u able to resolve this... am going crazy with this issue

muaz-khan commented 10 years ago

@Atrix1987, following namespace always worked for me:

var namespace = location.href.replace(/\/|:|#|%|\.|\[|\]/g, '');

You can remove spaces as well:

var namespace = location.href.replace(/\/|:|#|%|\.|\[|\| ]/g, '');

var namespace = location.href.replace(/\/|:|#|%|\.|\[|\| ]/g, '');
var firebaseURL = '//chat.firebaseio.com/';
var firebase = new Firebase(firebaseURL + namespace);

There is firebase-debug.js; you can check it to see how URL is parsed, etc:

https://www.webrtc-experiment.com/firebase-debug.js
34r7h commented 9 years ago

i'm having this issue only on gh-pages but works fine in development. any ideas?

muaz-khan commented 9 years ago

The only limitations that Firebase applies are:

A child node's key cannot be longer than 768 bytes, nor deeper than 32 levels. It can include any unicode characters except for . $ # [ ] / and ASCII control characters 0-31 and 127.

Description Limit Notes
Depth of child nodes 32
Length of a key 768 bytes UTF-8 encoded, cannot contain . $ # [ ] / or ASCII control characters 0-31 or 127
Size of one child value 10mb UTF-8 encoded
Write from SDK 16mb UTF-8 encoded
Write from REST 256mb
Nodes in a read operation 100 million

Ref: https://www.firebase.com/docs/web/guide/understanding-data.html

var firebaseChildNode = location.href
         .replace(/\/|:|#|\?|\$|\^|%|\.|`|~|!|@|\[|\||]|\|*. /g, '')
         .split('\n').join('').split('\r').join('');

var firebase = new Firebase('https://chat.firebaseio.com/'+ firebaseChildNode);