Currently, I am developing two webapps :
the core, developed in Java with Vert.x, receives data from a lot of other apps and sends it to client)
the client, developed in PHP/JS, display data from the core.
The client isn't on the same domain as my core for the production phase.
Since my development period, the two webapps are hosted in the same computer. I used "ws:\\localhost:9090" to connect my client to my core and I had no problem to transfer data.
But, today, I try to replace localhost with my IP Address and, it didn't work :s
I think that it's because the client isn't in the same domain as the core. But I don't know how I can correct this problem ?
Do you have any idea ?
Thanks !
Code example (based on my code but not my code ;) ):
For the core : http://pastebin.com/h2ZnBvQJ
For the client : http://pastebin.com/DR5BeABf
Yes, Websocket can do cross-domain, but you will need to have a handshake in order to get this going. You might want to take a look at: http://en.wikipedia.org/wiki/WebSockets for an example of a handshake.
Also related and maybe duplicate: Web sockets make ajax/CORS obsolete?
Related
im Trying to Write a Windows client-server Version control application .
i've created two servers , one works with java socket ( java.net library ) to handling the requests ( login, signup and ... ) coming from client . and the other server is running on FTP protocol (using apache common net library) for serving my files .
and client is able to communicate with the first server over tcp socket and download or upload files to the second server using FTP .
but recently someone just told me that i should use HTTP instead of both . because HTTP in java in really easy to use for both communicating and FILE serving and most importantly is its able to traverse the NAT which now what im using is not able to do .
now im wondering is he right ? should i change my servers to use HTTP instead of TCP socket and FTP ? whats the benefit ?
There's some advantages of changing your protocol stack to HTTP:
You can easily add security later (only a matter of a single 's')
You don't have to do two servers, you can do all-in-one.
At some point you could offer a browser-based access of you don't have the client installed / work of a decive where you cannot install it
HTTP webapps (even those in java) are proven to scale very, very well. So once you have a lot of users, you're still good to go.
There's a lot of helpful frameworks out there that can help you focus on the what instead of the how
Most companies that allow outside-access at all will have HTTP/HTTPS open. FTP is more limited in most places.
NAT traversal / Proxy traversal
and that's only the ones I came up with while typing :-)
Downsides:
You have to start over. But: If you run into trouble, Stack Overflow is there to help you out.
I am developing system, that consists of client (written in JavaFX) and server. Now I am going to implement server. Users will download clients. Clients will communicate with server (only one server and many clients). Server will communicate with data base and send results. Server will support authentication and different requests (not http of course). Is it a good idea to implement server with Java RMI? If no, could you advice me any good idea about server realisation.
Thanks a lot for future questions!
RMI is bit kind of traditional but still powerful to me ,it has some draw back . But, despite the RMI there is also a chance for you to use java sockets class ? just like a client -server application ...
I'm making a simple chat client using OpenFire 3.7.1 and SMACK 3.2.2 on a localhost. I wish to know if it is possible to establish 2 connection to the server from the same machine.
Illustration: I have made a working client for simple exchange of messages. I'll run two jar files of the client (containing a login prompt), I'll make two different logins for two different users.
Now I tried doing that, but got Stream:error which I know refers to connection too many times or 2 users or something like that. I don't know the exact details about that error. Your help would be appreciated. Thank you.
Yes, you can even do this from the same application. There are integration tests run from Smack that do this all the time.
You only have to make sure to log in with different JID's.
Recently i developed a simple chat application in java using sockets. It was working fine. But now i want to make an application which can communicate over the Local Area Networks like IPMSG. The features will be
message sending.
file sending.
voice chat.
group chat.
encryption/decryption on demand.
These were the basic features to be included.
Now the confusion i am facing over here is
The application is an peer to peer application in which one user can do anything what other users can do.
There is no centralized server and there in no client. Every node acts as a server and client both.
So the application has to be peer to peer. But when i googled it then i am getting samples like client-server only and when i talk to my peers regarding this then also they suggest me the client-server model but there is no justification for why client-server and why not peer to peer. Am i right in this case ? Can anyone please guide me in this case because once i start development on any of these concept i cannot revert back due to time shortage. Your suggestions are most welcome.
I think the main reason a server-client relation is advised, is to make it easier for logging, or make a large chatroom for everyone (like IRC). If there is a login required, the server would also verify the login details. So without a server in between, phishing attacks would become more difficult to deal with.
I don't see why a P2P chat wouldn't work, though. If I recall correctly, Skype is doing that. I always love decentralizing. Good luck with your project. :)
You might want to check out the Zeroconf standard and packages that use it like Avahi (linux FOSS) or Bonjour (Apple & Windows open-source but not GPL). Zeroconf allows for configuration and detection of network services without user interaction or a central configuration server.
I end up using a client server model modified to support to P2P networking. When a node comes into the network it broadcasts its presence and the other nodes are continuously listening for new nodes. Each node will have their own list for the connected nodes in the network. In case of new node coming into the network they will update their own lists. I am using UDP for all most all the operations except file transfer as it needs to be in TCP.
So I can limit my app with UPNP NATs capable clients. I would love to see any Opensource Java project using GAE as server for keeping maps like (ClientID, IP:PORT) (with example of some on clients simple hole puncher) Is there any such project?
Why not just stay with http transport, which usually works well with firewalls (otherwise users complain).
As long as you have the clients call you in the cloud, it should work well.