Comments (3)
I couldn't reproduce your issue, but then again I'm on Linux. How are you making requests to your server script? Using curl
or a browser? If you're using a browser you'll see two requests because the browser makes a second request to /favicon.ico
.
Please try the following code:
require 'bundler/setup'
require 'tipi'
puts 'Serving on http://localhost:4411/'
spin do
Tipi.serve('0.0.0.0', 4411, { reuse_addr: true }) do |req|
req.uri
req.respond("Hello world!\n")
rescue Exception => e
p e
end
p 'done...'
end.await
This will print the requested uri for each incoming request.
As for the server port leaking after the process terminates, I have also noticed that. Here's an explanation for what's apparently happening (from https://hea-www.harvard.edu/~fine/Tech/addrinuse.html):
In order for a network connection to close, both ends have to send FIN (final) packets, which indicate they will not send any additional data, and both ends must ACK (acknowledge) each other's FIN packets. The FIN packets are initiated by the application performing a close(), a shutdown(), or an exit(). The ACKs are handled by the kernel after the close() has completed. Because of this, it is possible for the process to complete before the kernel has released the associated network resource, and this port cannot be bound to another process until the kernel has decided that it is done.
The solution is to use the reuse_addr
option when calling Tipi.serve
, as shown in the above example.
from tipi.
Please note that the request / response API is still evolving, and has actually been extracted into a separate gem: https://rubygems.org/gems/qeweney. Documentation is lacking for the moment.
from tipi.
You're right, it was the favicon! Why did I not think of that 😬
Thank you for explaining the background of requiring reuse_addr
. Awesome gem, you've made! 😄
I'll check out qeweney -- noticed you're building a Roda style routing. I love the Roda/Sequel stack.
from tipi.
Related Issues (19)
- rack_server example problem HOT 3
- Benchmarks or comparison with Puma and friends? HOT 2
- http_parser as a runtime dependency HOT 1
- Change loading of Qeweney apps to use #run
- Supervision for websocket + Qeweney setup HOT 5
- Ruby crash, try to mark T_NONE object HOT 4
- Chunked encoding doesn't seem to work... HOT 1
- [Question] Is it compliant with Rack? HOT 5
- Implement streaming response compression HOT 3
- Different Ports for wss and https HOT 1
- extralite dependence update to version 2.0/2.1 HOT 1
- Implement Rack::Builder#use
- Ctrl+C on app throws ArgumentError
- Serving static files fails
- Server crashes when using gzip compression
- Application freezes when trying to connect to Mongodb HOT 1
- Improve compliance with Rack spec HOT 1
- Forked example doesn't work? HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tipi.