I'm trying to work with Socket.io and Django in a project and when I load the socket.io script from the server
<script src="localhost:3000/socket.io/socket.io.js"></script>
<script>
var socket = io();
</script>
I get an error because my Django project is in localhost:8000 so I dont know why the socket.io script is trying to do requests from Django when I said that the socket.io server is in port 3000.
In js console in my browser says
GET http://localhost:8000/socket.io/EIO=3&transport=polling&t=142197415699051
404 (NOT FOUND)
and that should be looking to loacalhost:3000 and not to localhost:8000
My Django log console says:
[22/Jan/2015 18:50:23] "GET
/socket.io/?EIO=3&transport=polling&t=1421974222989-62 HTTP/1.1" 404
7506
Obvously because theres not a Django url to answer that request.
How can I load a socket.io server in a Django template???
You can't specify what port a server-side application listens to from a client-side script src attribute.
You have to configure what port socket.io uses on the server-side.
See this StackOverflow for an answer on how to do that.
Related
I just uploaded my nodejs app on Heroku which makes a post request on my localhost 127.0.0.1 my localhost server is on PHP which takes a file and some data and generates an invoice but the problem is I get this error in the Heroku log when my deployed node server tries to make a post request to my PHP server using Axios.
enter image description here
You can see there is a message This is an error ignore that because I concatenated that with the error.
I would appreciate any help thanks.:)
I have a nginx server where I have an api deployed at localhost:5000
On the same server I have a Vuejs app which is deployed at localhost:3000 and then through nginx reverse proxy served from www.mysite.com.
the frontend uses axios to make calls to the api. But everytime it happens, I get a connection refused error to localhost:5000.
Why is this happening and how can I resolve it.
Note: If I serve localhost:5000 api also via a domain like api.mysite.com using nginx reverse proxy and call api from this domain then it works fine. But I don't want to do that and instead want to use localhost:5000 to call the api.
Please check the port is listed by using the following command if you use Linux
sudo netstat -tnlp | grep :5000
If there is process running, then fine. Try changing the localhost to 127.0.0.1:5000
I have deployed a web application in Heroku using node.js but within the application I need to make a request to an HTTP endpoint that returns a JSON file. While making the request, I get the a Mixed content error. I understand this happens because my application has been served through HTTPS but the request is HTTP. How could I tell heroku to serve my application as HTTP or what should I do to make it HTTP? Will this solve the problem?
I have set up a prerender server on my local machine.
It is on port 3033 and it seems to display a rendered version of my meteor site when I type this in
curl http://localhost:3033/http://localhost:3000/?_escaped_fragment_=
Knowing that my prerender site works, I'm trying to set it up so that if I go to
curl http://localhost:3000/?_escaped_fragment_=
it should give me my Meteor site.
I'm using this package (https://github.com/dfischer/meteor-prerenderio) and I've got this line in my settings.json file
"PrerenderIO": {
"prerenderServiceUrl": "http://localhost:3033/"
}
However, when I run
curl http://localhost:3000/?_escaped_fragment_=
it returns nothing and I'm getting this message shown up on my meteor server log
res.send(status, body): Use res.status(status).send(body) instead
and it doesn't seem to be hitting the prerender server.
What is this message and why aren't I able to hit the prerender server?
I upgraded my nodejs from 0.6 to 0.10
before socketIO works fine, but now whenever client request "socket.io.js"
"http://localhost:49991/socket.io/socket.io.js"
The response is only one line.
Welcome to socket.io.
Not the actual file "socket.io.js". My app crash because of this.
The output of sever console seems to be fine:
debug - served static content /socket.io.js
My socket.io version is 0.9.*. What could possibly be the problem here?
EDIT:
found this is duplicated:
Socket.IO client library gives "welcome to socket.io" message