2

My socket on the server is running on port 8081. On my client-side, I have:

<script src="https://www.server.co.uk:8081/socket.io/socket.io.js"></script>

and later on:

var iosocket = io()

However, when I load my page on port 80 (with the client-side code), I get an error saying:

Loading failed for the <script> with source: ..

and then

ReferenceError: io is not defined.

What is the issue here?

3
  • 1
    This happened to me after setting the CORS Access-Control-Allow-Origin setting. It would only work after removing the setting. I'm trying to find a more workable solution also.
    – Carl
    Commented Oct 4, 2017 at 18:34
  • Possible duplicate of Only on Firefox "Loading failed for the <script> with source"
    – Didier L
    Commented Nov 5, 2017 at 14:51
  • Possibly, yes, but the answer to that question explicitly mentions relative paths, which isn't the case here. I've also just experienced this error ('Loading failed...') on Firefox and to me it seems to be intermittent and my uBlock Origin claims not to have blocked request in question.
    – piemonkey
    Commented Dec 11, 2017 at 10:40

1 Answer 1

1

If the resource is ok with CORS, try disabling all the plugins in the page. In my case Privacy Badger blocked by default all the remote scripts to protect from tracker. Relaxed the check of Privacy Badeger on the site and all worked good.

Not the answer you're looking for? Browse other questions tagged or ask your own question.