-
Notifications
You must be signed in to change notification settings - Fork 10
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
[wsmc/Java] HTTP server returns 'Not implemented' on non-localhost hostnames #30
Comments
Figured this was caused by the
passing to ServerBootstrap bind, "0.0.0.0" wsAddress by default: Channel channel = bootstrap.bind(this.wsAddress, this.wsPort) |
bind(SocketAddress) : ChannelFuture all call into InetSocketAddress() constructor: http://docs.oracle.com/javase/7/docs/api/java/net/InetSocketAddress.html - "A null address will assign the wildcard address." Testing this: ChannelFuture channelFuture;
if (this.wsAddress == null || this.wsAddress.equals("0.0.0.0") || this.wsAddress.equals("")) {
channelFuture = bootstrap.bind(this.wsPort);
} else {
channelFuture = bootstrap.bind(this.wsAddress, this.wsPort);
} but no difference. Doesn't seem to be a problem in binding but in handling? |
ServerHandler pipeline is: @Override
protected void initChannel(SocketChannel socketChannel) throws Exception {
ChannelPipeline pipeline = socketChannel.pipeline();
pipeline.addLast("codec-http", new HttpServerCodec());
pipeline.addLast("aggregator", new HttpObjectAggregator(65536));
pipeline.addLast("handler", new HTTPHandler(this.webThread.wsPort));
pipeline.addLast("websocket", new WebSocketServerProtocolHandler("/server"));
pipeline.addLast("websocket-handler", new WebSocketHandler(webThread, this.mcAddress, this.mcPort, this.users, this.filter, this.verbose));
} first my code runs in HTTPHandler, but none of the `@Override'en methods in HTTPHandler are called when accessing over IPv4 (ok over IPv6). protected void messageReceived(ChannelHandlerContext ctx, FullHttpRequest msg)
throws Exception {
System.out.println("HTTPHANDLER MESSAGERECEIVED");
private static void copyStream(InputStream in, OutputStream out) throws IOException {
System.out.println("HTTPHANDLER COPYSTREAM");
public void httpRequest(ChannelHandlerContext context, FullHttpRequest request) throws IOException {
System.out.println("HTTPHANDLER HTTPREQUEST");
public void sendHttpResponse(ChannelHandlerContext context, FullHttpRequest request, FullHttpResponse response) {
System.out.println("HTTPHANDLER SENDHTTPRESPONSE"); need to find out where and what is returning the "Not implemented" response before I get it |
https://github.com/netty/netty/search?utf8=✓&q=%22Not+implemented%22 shows there are "501 Not Implemented" (notice capital "I") |
Using NetUtil.LOCALHOST4 (per netty/netty#4770, which was "Cherry-picked into 4.0 (52ba4f4) and 4.1 (3616d9e)" in Netty 13 days ago) correctly allows accessing the server over IPv4 at these URLs: http://127.0.0.1:24444/#testuser:VXVbHahf http://localhost:24444/ http://0.0.0.0:24444/ - but not my local (RFC1918) IP, nor the IPv6 local http://[::1]:24444/ nor the IPv6 global address. What I'm looking for is not a localhost IPv4 but "wildcard IPv4" (and/or wildcard IPv4+IPv6) |
+ socketAddress = new InetSocketAddress(Inet4Address.getLocalHost(), this.wsPort); allows using my IPv4 RFC1918 local network address, but not localhost, 127.0.0.1, 0.0.0.0, ::1, anything else. Am I really going to have to listen multiple servers for each interface? |
Turns out "Not implemented" is from wsmc/JavaScript (wsmc.js). Related: #31 [Broken] Update all dependencies (ws/websocket-stream) 🌴 |
Always something simple... (InetAddress) null = wildcard works correctly for both IPv4 and IPv6, lo0 and en1. Why I was seeing different behavior is that wsmc.js was erroneously running (user error, nonetheless non-informative error message) but only bound to IPv4 (bug/missing feature?), and wsmc.jar tried to bind everywhere but silently failed on IPv4 since the port was occupied so it only bound to IPv6 (missing error message?). |
Doesn't fix #30 either, but seems like a good idea
…tead of '0.0.0.0' which is IPv4-only. Closes GH-30
Fixed wsmc.js to bind to '' instead of '0.0.0.0' by default (IPv4+IPv6), now wsmc.jar gives a more informative binding error message:
|
http://localhost:24444/ - ok
http://127.0.0.1:24444/ - Not implemented
http://anythingelse:24444/ - Not implemented
Non-localhost hosts are very important so that the service can be reachable externally
The text was updated successfully, but these errors were encountered: