I am trying to obtain some education on websockets but I can't really find a decent tutorial. All tutorials out there instruct you to download a server and teach you how to use it. I'm more interested in how the server actually works and how I can control it on a remote host, like a hosting provider.
Anyway if I wanna learn there really aren't many options other than to download a built server and start inspecting. So I downloaded the server given in this tutorial http://dev.tutsplus.com/tutorials/start-using-html5-websockets-today--net-13270
The problem for now is that I can't even seem to connect to it. I'm running XAMPP on Win7, so it's completely relevant to the tutorial and appears quite easy, however I fail. I've managed to start the server, but when I open client.php I get
Firefox can't establish a connection to the server at
ws://localhost:8000/pol/newWS/server/startDaemon.php. var socket =
new WebSocket(host);
Fortunately chrome appears to provide a more detailed error message
WebSocket connection to 'ws://localhost:8000/pol/newWS/server/startDaemon.php' failed: Error during WebSocket handshake: 'Sec-WebSocket-Accept' header is missing
Javascript's host variable is set to 'ws://localhost:8000/pol/newWS/server/startDaemon.php', that's where the server is located on my localhost. I haven't made any changes to the server. Can anyone help me get this thing going? Thanks in advance!
Websockets in PHP are generally a pain in the ass. Even if you use a library like rachet you need to start it separately, not through a webserver.
As brad said, consider using node.js or the excellent autobahn.ws for python.
I just found some WS server I have downloaded in the past which works pretty well. I can't confirm for any security issues but if anyone knows or finds anything please don't spare us the sharing. I searched for some info in the comments but I couldn't find anything about the creator so I can't really give any credits.
files here
Related
I've written a webapp in php, which works as a standalone app, but needs to get/post new data from time to time to an API (written by a different company, for desktop software) on localhost. When connecting, it would be from a webpage/browser open on that machine.
So far I've attempted to send curl requests, basically using the generated postman curl code, and it's returning false. I'm thinking it's because it can't connect to the localhost server, possibly because it's blocked from the internet.
I've been researching for a few days, but want a solution that doesn't involve me creating security vulnerabilities in the computers I am trying to connect to, by opening them directly to the internet, and if there is a way to send requests to localhost without installing more software on them I would be partial to that kind of setup.
Does this make sense? I hope someone has some experience or wisdom in this area that could at least nudge me in the right direction.
The localhost is always the computer where you refer to that host. You can't connect to the localhost from your webapp, because the localhost hostname for that app is the computer which runs it.
You have to open a tunnel from you computer to the internet where you webapp can communicate with it.
You can use ngrok to do that, for example
I am trying to establish a XMPP connection to talk.google.com on port 5222, however I am getting a 301 MOVED PERMANENTLY response redirecting me to hangouts.google.com.
I know Google abandoned GTalk, and what I could find is really inconclusive of whether the service is actually still up and running (although not maintained), or not.
I almost gave up thinking it is just not there anymore, however last try using external client (Adium...like Pidgin but for Mac) instead of my own library (XMPP-PHP), ended up actually connecting to the server and sending messages all fine.
Is there something I'm missing?
You want to do an DNS SRV record lookup to find the actual server to connect to, eg https://kingant.net/check_xmpp_dns/?h=gmail.com says that the client records for gmail.com's XMPP server are xmpp.l.google.com and alt{1..4}.xmpp.l.google.com
Alternatively, you could use a hangups-based solution to speak the native Hangouts protobuf format: https://github.com/tdryer/hangups/
I have found the right URL to be talk.l.google.com.
I have viewed and studied many tutorials including Apple Document but i can't find a way to create my own service provider server for apns. In this link http://www.raywenderlich.com/3443/apple-push-notification-services-tutorial-part-12 they gave us a sample php server and hard code our device token to receive the push notifications. But, am looking for to create a php server and how to host the php server in local web site. Am not a well familiar in db/server side work that's why am struggling. Can anyone please explain me or suggest any tutorials to create a php server and host the server in local? How to save all device tokens in the server from our device? Please help me. Thanks in advance. I have spent two days in this topic please save my day. Thanks.
If you don't want to create a server your self, there is an easier ready to use solution
In one of my projects a PHP server is successfully serving a php client via sockets but when I try an iPhone client using the NSStreams to this PHP server the client gets connected but if I send a string from the client to server, the xcode comes up with error message that connection is broken.
If I use the same iPhone client to connect to a server running on Python, it establishes the connection and strings are being read/written without any problem.
Can someone understand this please? If some sample or tutorial on PHP / iOS applications on sockets then I will be obliged.
hi you can use WebSocketServer located on http://code.google.com/p/phpwebsocket/ and on Iphone clien http://www.raywenderlich.com/3932/how-to-create-a-socket-based-iphone-app-and-servert
i cant repost my code here, because SO considers it spamming to repeat your answer.
check out this sample code and tutorial link. works like a charm and is really simple to implement, less than 3 minutes and you are up and going (IF you have a socket server ready).
as a general rule, php might not be the best solution for a socket server. i like working with c++ or python better. just holler if you need some sample code for a socket server using c++.
also, it is VERY VERY VERY important to check if your server has open ports. unless you are using your own server, chances are that your hosting package does NOT open ports. a virtual private server is necessary for that. at this time, i strongly recommend amazon's AWS EC2 servers.
in case you have difficulties with it, i can give you a couple of nudges in the right direction.
I know this kind of thing cannot be adequately answered without a link to the live example. Unfortunately, I can't set one up right now as it's a back-end login and creating a safe public login would be too much to do at this point. Sorry. I'm hoping for ideas and input from people who may have experienced something similar in the past.
I am setting up a CMS for a client with a DSL connection in Spain.
The CMS is hosted on a straightforward standard, LAMP based, shared hosting package in a network center in Germany.
It comes with a .com domain.
When my client tries to log in to the CMS using Internet Explorer 7, everything works fine.
When she tries to log in using Firefox, she gets to the login form, submits it - and then the connection times out.
When she logs in using Firefox but using "domain.com" instead of "www.domain.com", everything works fine.
This happens on all computers that are hooked up to that line. One Windows XP, one Windows Vista.
The front-end part of the site, as well as a second, older CMS, work fine in all browsers.
I do not have access to the raw access logs.
I have not been able to reproduce this behaviour on any other connection.
Debugging ideas are welcome. Remote diagnosis is extremely difficult as the line is too slow to set up a proper remote connection.
If you are limited by how you can troubleshoot this, have the client install Fiddler - Web debugging proxy and then run the trace, and send you the logs, Fiddler will analyze the traffic (be it proxy or DNS timeout, etc)
Take a look if you have not used it before:
http://www.fiddler2.com/Fiddler2/version.asp
Check that Firefox and IE are using the same proxy settings.
DNS issues? can you put here your A records to check is everything is ok?