Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

websocket server serving url request (or static files) #58

Open
ellLazar opened this issue Apr 22, 2016 · 8 comments
Open

websocket server serving url request (or static files) #58

ellLazar opened this issue Apr 22, 2016 · 8 comments
Labels

Comments

@ellLazar
Copy link

how the web socket serving static files (URL) ? means:
in client javascript:
image.src=url1 ;

websocket server:
getting the url1 request, and sending back to client the binary image.

I tested your vtortola websocket with strings,on concurrent users,
it worked perfectly.

any code sample, or link will be appreciated.

@vtortola
Copy link
Owner

vtortola commented Apr 22, 2016

Hi!, the component does not serve HTTP content.

You may want to take a look to HttpListener. The only thing is that you will need to run the websocket server and the http server in different ports.

Cheers.

@ellLazar
Copy link
Author

from your wiki,
1.
I think I saw that you give additional protocol http (request,response)
so I can serve files additional to websocket (same port) ?

  1. on client javascript image.src=url,
    what the web socket onMessage is getting ?
    any string request ?, if yes we can handle this from binary response.

@vtortola
Copy link
Owner

I think you have seen the part about custom HTTP negotiation, but it is only to hook some logic in case you want to check for example headers like Cookie or Origin and return custom HTTP errors. You cannot use it to serve HTTP content.

You will get nothing. The websocket protocol uses HTTP only for connection establishment and after that it uses its own binary protocol. Even if the browser tries to open a ws connection to the url you put in image.src, it won't try to send a message.

@Slyb00ts
Copy link

it still would be really nice to add really simple http communication, for example it could be added like this:
http://127.0.0.1 will server http files
http://127.0.0.1/socket would serve websockets
Please consider this :) BIG THUMBS UP for http static files ;)

@vtortola
Copy link
Owner

I understand it is something that seems convenient, but definitely this is something I won't add, since it goes beyond the WebSocket spec.

Cheers.

@ellLazar
Copy link
Author

node.js is giving actually :static file serving and stream
I also got some info about in other github, that serving static files(images,..) using :back proxy with IIS

@jboecker
Copy link

@ellLazar: I was looking for a C# WebSocket server that also had a minimal HTTP server to serve a single-page web app and ended up using https://github.com/sensaura-public/iotweb. Unfortunately, its API does not use async/await (which is why I'd have preferred WebSocketListener).

@ellLazar
Copy link
Author

I also asked this qeustion, on other site
how to combine serving websocket and http requests, I have been told it can be achieved
by settings reverse Proxy in IIS, and this mechanizm can "steal" the http reuqests.
I did not test it, because for me, it's not simple settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants