question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using namespace will ignore port, or default to port 80

See original GitHub issue

What’s wrong:

I have the socket.io service running on port 4040 (for example), which exposes namespace /chat. From the client side, if I try to connect to the namespace without specifying the full url, the window url will be used without the port (or default to port 80).

What works:

From the client side, connecting to the default namespace is still okay, e.g. io.connect() or io() will correctly connect with the full url 192.168.0.149:4040. Needless to say the full url works.

Repro Code

# app.coffee
express = require 'express'
io = require 'socket.io'
http = require 'http'
app = express()
server = http.createServer(app)
io = io.listen server

server.listen 4040

app.use(express.static "#{__dirname}/public")

chat = io.of 'chat'

chat.on 'connection', (socket) ->
  socket.emit 'welcome', 'howdy'

# index.html
<!DOCTYPE html>
<html>
  <head>
    <title>Chat with port demo</title>
  </head>
  <body>
    <h1>Chat ip demo</h1>
    <script src="/socket.io/socket.io.js"></script>
    <script>
      var socket = io('/chat');
      socket.once('welcome', function (message) {
        console.log(message);
      });
    </script>
  </body>
</html>

# package.json
{
  "name": "socdemo",
  "version": "1.0.0",
  "description": "",
  "main": "app.coffee",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "express": "^4.11.2",
    "socket.io": "^1.3.2"
  }
}

# error (misleading error since it's because there is nothing running on 192.168.0.149:80)
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://192.168.0.149/socket.io/?EIO=3&transport=polling&t=1422967677888-0. This can be fixed by moving the resource to the same domain or enabling CORS.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:56 (7 by maintainers)

github_iconTop GitHub Comments

4reactions
nkzawacommented, Jan 16, 2016

Fixed in 1.4.x.

0reactions
JustBlackBirdcommented, Dec 9, 2015

@yamsellem it’s not only a way to subscribe but also a way to show maintainers how many people face the problem.

Read more comments on GitHub >

github_iconTop Results From Across the Web

networkpolicy to isolate namespace and pod with port
Create a new NetworkPolicy named allow-port-from-namespace that allows Pods in the existing namespace internal to connect to port 80 of other ...
Read more >
How to know who is listening to port 80 on Windows in ...
Well, let's make it an answer. What you're seeing is most likely the result of a program using http.sys the Windows Kernel Mode...
Read more >
Uri.Port Property (System) | Microsoft Learn
The following example writes the URI port number to the console. In this case, the value is the default port number for HTTP,...
Read more >
Validation | Kiali
Kiali validations are based on the runtime status of your service mesh. ... use istio default controller servers: - port: number: 80 name: ......
Read more >
Service | Kubernetes
Port definitions in Pods have names, and you can reference these names in ... The default protocol for Services is TCP; you can...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found