Hey, I'm trying to test this on a google cloud ser...
# kweb
b
Hey, I'm trying to test this on a google cloud server but I'm getting this warning
WARN io.netty.util.internal.MacAddressUtil - Failed to find a usable hardware address from the network interfaces; using random bytes:
Which I think is not allowing it to work
i
Ah, I've seen that, let me try to remember....
Hmm, is it actually preventing your app from working? I think it’s a Netty issue (which kweb uses), but from what I’m reading it should be harmless
b
Is says it's listening but I can't connect. I figured that it is it's own webserver and I don't need to install apache or anything
i
That’s correct, Kweb is standalone
where are you trying to connect from? Could it be a firewall issue?
I have tested Kweb on Google Cloud, but it was a few months ago
b
I'm trying to connect with the external ip from the vm console. I can check the firewall rules. So far it has http/https traffic enabled
i
as an experiment, it might be worth checking using curl from the command line
(obviously kweb won’t like this, because curl doesn’t support javascript, but you should at least pull down some HTML)
command line on the google cloud instance, that is
you’ve configured kweb’s port to 80?
b
yup!
It's just a simple hello world that works on my main computer
i
what is the console output from kweb? (you may need to set up a logger to get output)
b
I'll have to recompile it to get the logs to see if anything is happening
i
Ok, unfortunately I think that might be necessary to diagnose further
b
I did
curl 35.197.37.165
and nothing. I'll get back to you with the logs and see what it says
i
But rest assured that I’ve got kweb working on Google Cloud in the past, it’s probably something silly 🙂
b
thanks for being quick with the responses!
i
I aim to please 😉
Thanks for trying kweb 🙂
b
I am running the server using
java -jar name.jar
I tried
curl 127.0.0.1:80
and it's saying connection refused 😕 even though it's in my processes as running I also did
debug = true
and nothing is popping up as even trying to connect
i
so there is no console output whatsoever? Is there a logger implementation? eg.
compile group: 'org.slf4j', name: 'slf4j-simple', version: '1.6.1'
b
I have that added. All I have to do is just
debug = true
in the Kweb arguments?
i
it should be producing console output with or without debug = true
after you type
java -jar ...
there is no console output whatsoever?
b
I get this
Copy code
630 [main] WARN io.netty.util.internal.MacAddressUtil - Failed to find a usable hardware address from the network interfaces; using random bytes: 46:20:64:35:c9:bf:39:34
712 [main] INFO io.kweb.Kweb - KWeb is listening on port 80
i
hmmm
b
Do I need to set the superuser bit?
i
ah, that might be it - you might need to run it as sudo
because port 80 is reserved
surprised that doesn’t generate an error though
b
running it as sudo gave me some results when I use curl
i
that’s promising…
b
Still can't connect from the external ip though
i
external ip but still from the machine itself?
b
just tested curl on my home machine. It works when trying the external ip
but in a browser it doesn't parse
i
what is the browser error?
b
It's saying it refused to connect
ERR_CONNECTION_REFUSED
i
so curl works, browser doesn’t, but curl and browser are doing the exact same thing?
b
aha!
typing the IP in the browser defaults to https
i
ah
b
however I'm only listening to port 80
i
bingo
b
So the fix is a) run as su and b) make sure you're not using https
i
yeah, kweb doesn’t support HTTPS yet. It should be very easy to add (since netty does the work), but hasn’t been done yet
b
Is there a way to redirect traffic to port 80 if it sees a call to 8080 has been made?
that might be something I can do in the VM instance
i
probably, some kind of proxy that decodes/encodes the HTTPS to HTTP
also probably not too hard to improve Kweb to do it, if you are feeling a tad more ambitious
b
without an ssl cert is there any encryption actually happening besides just saying https:// in front of the url
I just might have to look at the source.
I'm getting a ton better at Kotlin so it might make some sense
i
yes, it will encrypt I think, but they’ll probably get a nasty browser warning
You shouldn’t need to grok everything going on in that class to extend support to include HTTPS, it’s mostly just understanding the points of contact with Ktor (which wraps Netty)
b
I'm wondering if I could make Kweb listen on a list of ports instead of just one
i
That class needs to be broken up and simplified
I don’t see any reason it couldn’t listen on multiple ports, but note that there is more to HTTPS than just listening on the HTTPS port
browsers will probably throw a fit if they find a HTTP server on a HTTPS port, as they should 🙂
b
I unfortunately don't know anything about how the web works. My Networks class didn't do a great job haha
i
HTTPS is mostly just HTTP wrapped in an encryption layer
b
So it essentially just needs to check if it's being contacted by the https port, if it is, decrypt it with a key that we provide
i
but I don’t think you’ll need to get into the weeds of that, since Ktor should have explicit HTTPS support
Right, but Ktor/Netty should handle that
b
I will look into Ktor then and see how it does it
i
you’ll just need to tell it what port to listen to, and make sure it knows it’s supposed to be a HTTPS server, not HTTP
then there are certs, but again, Ktor should handle that plumbing
the guys on #ktor are normally very friendly and helpful
And if you can create a kweb pull request, I’m more than happy to review and merge
b
So is Kweb essentially a big wrapper so you don't have to deal with all the routing stuff of ktor? Kweb let's you start on a website NOW instead of figuring out the details
I'll do that! I'm trying to get employed so contributions will be great for prospective employers
i
Kweb occupies a funny place in the normal web software stack. It’s a bit like React + Node.js, because it straddles both web server and web browser
b
That's why I'm using it. I hate JS so was looking for a Kotlin solution
plus debugging is wayyyy easier
i
Ktor handles everything up to routing HTTP/HTTPS, kweb shits on top of that
erm, “sits”
b
haha
i
possible “shits” too, time will tell 😉
b
dang dude, you have your own wiki page. I might be talking to the next linus torvalds of the web world
i
Nah, I don’t have a cool Finnish accent