I have read somewhere in google that we can't send files through web sockets but I also read that websockets are using TCP. So I want to ask what had I misunderstood and is there a way to send file through web socket.
File uploads should be possible through websockets, at least in html5. One ready-made library which provides some basic functionality is Water under Ice.
There's an article on Changelog about it, go and read it.
Yes it is possible. You can read file system using File API, then get resulting data to Javascript array/string and then put this content to a websocket message.
Related
I'm developing an audio streaming platform like Spotify for a school project. I used Vuejs for the front-end application and implemented an audio player. This is working.
Now I need a way to send audio files from a back-end to my front-end. I now have a micro service called streaming service using Spring Boot and used WebSocktets (STOMP) to make a connection with the front-end. But I see it's mostly used for chat applications or conference call applications..
I read it is heavy to send audio files via REST, because of making connections repeatedly. Which way is the most efficient way to implement this?
Please be specific in your answer since I'm not a advanced developer
I read it is heavy to send audio files via REST, because of making connections repeatedly.
Not really. For something like Spotify, a normal HTTP Progressive stream is sufficient. In this case only one TCP connection is typically made, over which a small handful of ranged HTTP requests will go over.
Web Sockets are only appropriate for cases where you need a bidirectional data flow. In this case, you just have requests and responses, which a normal HTTP request is suitable for.
Usage of regular HTTP also means you can utilize standard CDNs.
I'm developing a scholar project where I have a core written in Ada language that generates data information.
As requested by the project, I need to send all the new produced information, with a certain period, to a remote webserver via websocket.
In javascript language is really easy to connect to a web socket:
var exampleSocket = new WebSocket("ws://www.example.com/socketserver", "protocolOne");
I would be able to execute a similar command in Ada, is it possible?
May be possible to workaround the problem calling an html page (with GET parameters) containing javascript code so that this page manages the websocket with remote webserver?
For those still looking for this answer; AWS now supports websockets...
https://docs.adacore.com/aws-docs/aws/high_level_services.html#websockets
Both AWS and Black has supports websockets. AWS is the most mature of the two, so I suggest that you use that.
Is it technically possible to create a WebRTC connection for transferring JSON between two WebRTC endpoints spawned in the same script on the same page in the same browser?
For example, could I code an HTML5 offline app to communicate between different parts of the app over "local" WebRTC?
This is not a question about whether this is a good idea or whether I should be doing something a different way! Just "is this technically possible?"
No, this is not possible, because the implementation of web sockets in a browser are client implementations. For point-to-point communication you would need a web socket server instance, which you cannot create in a browser.
Maybe, you should have a look at WebRTC.
You can find a very good sample in this web: https://bitbucket.org/webrtc/codelab
To be more exact, in the step 5:
"In the examples already completed, the 'sender' and 'receiver' RTCPeerConnection objects are on the same page, so signaling is simply a matter of passing objects between methods.
In a real world application, the sender and receiver RTCPeerConnections are not on the same page, and we need a way for them to communicate metadata."
You can run the samples to understand better how it works.
I'm trying to move a large amount of files from one CDN to another. I know that they have a very high-speed connection to each other, so what I'd like to do is connect them directly, but the only protocol I have access to with each is FTP. Is there any way to log into the current CDN and send their files to the other FTP? It seems like it should be possible, I just have no idea how to do it.
FXP: see Wikipedia article. Powerful FTP clients are capable of doing this. From protocol point of view it's trivial.
BTW this question is probably offtopic here.
I've always wanted a way to make a socket connection to a server and allow the server to manipulate the page DOM. For example, this could be used in a stock quotes page, so the server can push new quotes as they become available.
I know this is a classic limitation (feature?) of HTTP's request/response protocol, but I think this could be implemented as a Firefox plugin (cross-browser compatibility is not important for my application). Java/Flash solutions are not acceptable, because (as far as i know) they live in a box and can't interact with the DOM.
Can anyone confirm whether this is within the ability of a Firefox plugin? Has someone already created this or something similar?
You may want to look at Comet which is a fancy name for a long running HTTP connection where the server can push updates to the page.
It should be possible. I have developed a xulrunner application that connects to a TCP server using sockets. Extension development would likely have the same capabilities. I used a library from mozdev - JSLib. Specifically check out the networking code. The fact that there is a Firefox add-on for JSlib add-on for Firefox makes more more confident.
Essentially, as I understand it, sockets are not part of JavaScript, but through XPCOM, you can get raw socket access like you would in any c/c++ application.
Warning: JSLib doesn't seem to receive a lot of attention and the mailing list is pretty sparse.
Java/Flash solutions are not acceptable, because (as far as i know)
they live in a box and can't interact with the DOM.
That's not actually true of Java. You can interact with Java via JavaScript and make DOM changes.
http://stephengware.com/proj/javasocketbridge/
In this example there are two JavaScript methods for interaction
Send:
socket_send("This was sent via the socket\n\n");
Receive:
on_socket_get(message){ more_code(message); }
You may want to look at Comet
a.k.a. server push. This does not let the server "update" the client page directly, but all the new data is sent to the page through a single connection.
Of course, a Firefox extension (as well as plugins, which are binary libraries that can do whatever any other application can do) can work with sockets too. See 1, 2.