0.6.0 Build from master -> ReferenceError: SIP is not defined

376 views
Skip to first unread message

SD

unread,
Jul 19, 2014, 2:23:19 AM7/19/14
to sip...@googlegroups.com
Hi 
I attempted to build 0.6.0 from master... the build process looked like it completed successfully, however I am not able to instantiate a SIP UA  
When I revert to the pre-compiled 0.6.0 download from the website, it works properly.   Does anyone else experience this?  Is the master trunk broken or am I doing something wrong?
thanks

var userAgent = new SIP.UA({ uri: 'b...@example.onsip.com', wsServers: ['wss://sip-ws.example.com'], authorizationUser: '', password: '' });
ReferenceError: SIP is not defined

Eric Green

unread,
Jul 19, 2014, 8:58:33 AM7/19/14
to sip...@googlegroups.com
Hi SD,

I cannot reproduce this. I know this might seem silly, but can you confirm a few basic things for me?
1) Did SIP.js actually compile successfully. We have updated jasmine among other things. Maybe a dependency is missing.
2) Are you including SIP.js correctly. I know that you were using 0.5.0 and some file names have changed so maybe it is just pointing to a missing file?

Thanks,
-Eric Green

SD

unread,
Jul 19, 2014, 9:54:08 AM7/19/14
to sip...@googlegroups.com
Thanks Eric

As far as I can tell, SIP.js built correctly.  I am following the instructions from here https://github.com/onsip/SIP.js/blob/master/BUILDING.md

Check out the attached text file "output-from-building-SIPjs-0.6.0-master.txt" ...this is the output from the console from building it.  I am building on Ubuntu which I have done several times in the past on the 0.5.0 version successfully.

Also see attached file "mybuild-NOT-WORKING-sip-0.6.0.js"  which is the file that I built and the attached file "prebuilt-download-WORKING-sip-0.6.0.js".   (Note for purposes of this posting and attachment, I have added the 'mybuild-NOT-WORKING-'  and 'prebuilt-download-WORKING-' prefixes to the respective file names.  When I am actually using the files they are simply named 'sip-0.6.0.js').   

When I include the prebuilt file in my project, it works.  When I replace it with the mybuild file, it causes the   
ReferenceError: SIP is not defined

Thanks again for your help.
output-from-building-SIPjs-0.6.0-master.txt
mybuild-NOT-WORKING-sip-0.6.0.js
prebuilt-download-WORKING-sip-0.6.0.js

Joseph Frazier

unread,
Jul 19, 2014, 11:42:40 AM7/19/14
to SD, sip...@googlegroups.com

(Typing from phone) can you use `git bisect` to find the commit that breaks things?

--
You received this message because you are subscribed to the Google Groups "SIP.js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sip_js+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

SD

unread,
Jul 19, 2014, 1:43:20 PM7/19/14
to sip...@googlegroups.com, sdel...@gmail.com
Thanks Joe
I have never done that before...but looking into how...

Joseph Frazier

unread,
Jul 19, 2014, 5:20:15 PM7/19/14
to SD, sip...@googlegroups.com

You might have found this by now, but it looks like your problem isn't in the compilation stage. Open http://JSFiddle.net/P7bNY , which uses your build, and see the js console log.

How are you including the compiled file in your application?

SD

unread,
Jul 19, 2014, 5:34:50 PM7/19/14
to sip...@googlegroups.com, sdel...@gmail.com
Thanks Joseph,
But I am not following you.

I include my compiled file in exactly the same way that I have included the downloaded file.  just replaced the file
thanks
SD

Joseph Frazier

unread,
Jul 19, 2014, 5:45:15 PM7/19/14
to SD, sip...@googlegroups.com

(Still on phone BTW)

Can you recreate the JSFiddle locally, with an index.HTML that only includes your sip.js build, logs out the value of window.SIP, and does nothing else? It sounds like the rest of your application code may somehow be causing the problem.

Note that browserify is now used to compile sip.js. You might want to see if that commit is the one that things break with. https://github.com/onsip/SIP.js/commit/ba42061de02081de967c9448b139a41626cade56

SD

unread,
Jul 19, 2014, 10:48:27 PM7/19/14
to sip...@googlegroups.com, sdel...@gmail.com
Its very strange....
Inside of my project, when I include my build of the master, I received the reference error.
When I create a test project that just tries to instantiate the SIP UA, it works.

scratching head....

SD

unread,
Jul 19, 2014, 11:07:58 PM7/19/14
to sip...@googlegroups.com, sdel...@gmail.com
I think I am closing in on the issue.

I am using requireJS  http://requirejs.org/ to load the SIP.js file in my project.
when I directly include the file from the html page with a tag like below, it works...
<script type="text/javascript" src="sip-0.6.0-devel.js"></script>

However, with requireJS, I have javascript code to include the file, it fails.    

It has always worked before and does work with the downloaded version of 0.6.0.

Joseph Frazier

unread,
Jul 20, 2014, 12:35:19 PM7/20/14
to sip...@googlegroups.com, sdel...@gmail.com
Ah, in that case, please see http://jsfiddle.net/cAzeE/2/, which uses requireJS to include your build.

Thanks,
Joseph

Joseph Frazier

unread,
Jul 20, 2014, 12:38:41 PM7/20/14
to sip...@googlegroups.com, sdel...@gmail.com
Sorry for the double-post, but I forgot to mention the article that helped me make the fiddle. It has a little more context about how SIP.js uses browserify to generate a universal module.

SD

unread,
Jul 20, 2014, 9:45:28 PM7/20/14
to sip...@googlegroups.com, sdel...@gmail.com
Thanks Joseph!

Unfortunately, that still does not work.   Check out the attached files...

I have setup a sample requireJS main.js file which attempts to include the downloaded or the built version of the SIPjs 
When I include the downloaded version it works properly.... but when I change it to use the built version it does not work.

thanks in advance for your help
sip-0.6.0.js
sip-0.6.0-devel.js
testApp.js
index.htm
main.js
requireJS.js

Joseph Frazier

unread,
Jul 21, 2014, 1:29:55 PM7/21/14
to sip...@googlegroups.com, sdel...@gmail.com
Hey, sorry to hear you're still having trouble. Unfortunately, I'm not familiar enough with RequireJS to know what's going on here (I actually only learned how to use it for my last post). However, I'm fairly confident at this point that browserify is building a proper AMD module of SIP.js, so I'm inclined to think that your problem lies with the way you are using RequireJS.

If you like, you could load SIP.js in a separate script tag before RequireJS, so that it defines window.SIP instead of defining an AMD module (see http://jsfiddle.net/cAzeE/3/). Another alternative would be to use browserify to build your app instead of requireJS, so that you can load SIP.js the node way; browserify-ftw might be able to help you with that.

Cheers,
Joseph

SD

unread,
Jul 21, 2014, 1:35:53 PM7/21/14
to sip...@googlegroups.com, sdel...@gmail.com
Thanks Joseph
I am able to get the SIP.js to work if I put in a separate script tag.
I have been using requireJS since I started my SIPjs project, and not experienced any issue until now.

I am really troubled by not understanding what has changed to cause the loading of SIP.js through the requireJS system to fail.


Thanks

Joseph Frazier

unread,
Jul 21, 2014, 1:54:39 PM7/21/14
to sip...@googlegroups.com, sdel...@gmail.com
When SIP.js switched to using browserify for the build process, it likely began to interact with requireJS differently than it did before. Before that commit, SIP.js used some custom code in the tail.js file to define its AMD module. Now, SIP.js lets browserify take care of the AMD definition, by using browserify's --standalone option. See my previously referenced link for more information about how that happens. As I said before, I don't know exactly what changed, but I was able to modify the requireJS.js file from your earlier post to work correctly with your SIP.js build: http://jsfiddle.net/e2UAm/

Good luck,
Joseph

SD

unread,
Jul 21, 2014, 2:15:40 PM7/21/14
to sip...@googlegroups.com, sdel...@gmail.com
Joseph,
Thanks for the explanation!
 I was able to modify the requireJS.js file from your earlier post to work correctly with your SIP.js build: http://jsfiddle.net/e2UAm/
Does that mean you were able to get it working?   I am not sure I could find what changed.
thanks!

Joseph Frazier

unread,
Jul 21, 2014, 2:20:09 PM7/21/14
to sip...@googlegroups.com, sdel...@gmail.com
Thanks for the explanation!

You're welcome, I'm glad I got to learn about this stuff too.

Does that mean you were able to get it working?

Yes, all I did was modify the 'sip-built' path to point to your build that you linked earlier, then I required that path. Note that the SIP object is correctly logged to the console. It seems like the path you are using locally might not be correct.

Joseph Frazier

unread,
Jul 21, 2014, 2:22:48 PM7/21/14
to sip...@googlegroups.com, sdel...@gmail.com
Oops, it was actually your main.js file that I modified, not requireJS.js.

SD

unread,
Jul 21, 2014, 2:23:04 PM7/21/14
to sip...@googlegroups.com, sdel...@gmail.com
hmmm... that doesn't work here ... The SIP object does get logged to the console, but then not usable by the test application.

Joseph Frazier

unread,
Jul 21, 2014, 2:33:57 PM7/21/14
to sip...@googlegroups.com, sdel...@gmail.com
Ok, I see what's happening. Your application is assuming that SIP.js is exposed as the window.SIP object, which was the case when SIP.js had its tail.js file that did that along with defining the AMD module, but is not the case now that browserify is defining the AMD module without setting window.SIP. You can fix this by requiring SIP.js from your testApp.js, or you can get around it by manually setting window.SIP after it is loaded by require. See line 11 of http://jsfiddle.net/e2UAm/2/ for an example of the latter solution.

Thanks,
Joseph

SD

unread,
Jul 21, 2014, 2:55:33 PM7/21/14
to sip...@googlegroups.com, sdel...@gmail.com
Eureka!!
yes ... That resolves the problem.   
window.SIP = SIP
Thank you very much for sticking this one out with me :)

Joseph Frazier

unread,
Jul 22, 2014, 11:38:27 PM7/22/14
to sip...@googlegroups.com, sdel...@gmail.com
You're welcome, it's nice to know everything's working for you now! Since SIP.js 0.6.1 has been released, I've added a note there for anyone else running into a similar problem.
Reply all
Reply to author
Forward
0 new messages