The current Ruby language is hot among programmers, and the open source community is constantly having new ruby apps. Thin and Sinatra are the best of the Times.
But new things always have a maturity, just as any upgrades have a price. Sinatra and Thin together, in some scenarios there are problems.
The author encountered the situation is like this.
The author's application structure is as follows:
Web Browser--> nodejs--> Thin-->
The problem appears on the path of Nodejs--> Thin: Thin parsing the JSON data sent by Nodejs error, Thin received JSON data, the original data will be preceded by a string of numbers, the sample is as follows:
88
{"XX": "A", "yy": "B"}
0
Through the Google search solution, it is found that nodejs and thin are incompatible. The way to solve this problem is to choose one of Nodejs and thin, and later I changed the thin, using Ruby native Web container webrick. The way to use Webrick in Sinatra is:
Rackup-p 8090-s Webrick