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

Example of connecting to a database #51

Closed
x20mar opened this issue Jul 20, 2012 · 2 comments
Closed

Example of connecting to a database #51

x20mar opened this issue Jul 20, 2012 · 2 comments

Comments

@x20mar
Copy link

x20mar commented Jul 20, 2012

Hey,

Is there any chance you could provide an example on how to use websockify in connecting a querying a database like mysql or postgresql?

Thanks

@kanaka
Copy link
Member

kanaka commented Jul 20, 2012

@x20mar I won't have time to do this personally, but if somebody wants to code up a simple example then I'm willing to include this as an example in the repo.

@ysangkok
Copy link

it's pretty straightforward. for pgsql, launch like this: ~/websockify/websockify.py 5432 -- /usr/lib/postgresql/9.1/bin/postgres -D .

i made a fork of node-postgres here on github to make it work in the browser. there are issues because websockify seems to discard data just before connection close, which makes error messages about wrong login disappear, i'll make an issue for that.

to find out what to send over the websocket, you can use wireshark on a psql session.

i also made a quick modification of wstelnet.html to test out pgsql over websocket, it's here: https://gist.github.com/3779549 instructions:

  1. adjust hex data (using data from wireshark, or by looking at it in ascii).
  2. open connection to websockified pgsql.
  3. click part1 (postgres handshake)
  4. click part2 (postgres login)
  5. click part3 (postgres query)
  6. click part4 (postgres logout)

here's a screenshot: http://i.imgur.com/EipJ9.png

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

No branches or pull requests

4 participants