WebSockify & IMAP

772 views
Skip to first unread message

duane

unread,
Jul 29, 2014, 8:51:42 PM7/29/14
to no...@googlegroups.com
Hi Everyone,

I'm trying to make an email client within the browser that uses WebSockets to load emails via IMAP. Is WebSockify something that I could use to make this work? I'm hoping to make a simple proof-of-concept that will display a list of emails from a Gmail account. I'm new to the various email protocols and will be so thankful for any insights anyone can provide (or even just a Yes/No WebSockify can be used successfully for this purpose).

Thank you so much in advance!

-Duane

Joel Martin

unread,
Jul 31, 2014, 9:06:16 AM7/31/14
to no...@googlegroups.com
Duane,

Short: Yes.

Longer:

Websockify is a proxy/bridge between WebSocket and TCP and as such, a web app client can connect to any sort of TCP server. As a reference, you could look at IMAP implementation already done in Javascript (node.js). For example: https://github.com/mscdex/node-imap

The top level of the websockify repo also contains the beginning implementations of telnet and IRC clients.

Here are some other resources:

Websock.js (client) API:

IMAP protocol:

Regards,

Joel Martin (kanaka)

duane

unread,
Aug 1, 2014, 8:10:45 PM8/1/14
to no...@googlegroups.com
Thank you so much for the detailed information Joel!

I have managed to get a successful round trip to a simple echo-server through the websockify proxy and back to the browser, but I'm unable to get one working through ssl.

I'm trying to proxy the gmail imap server this way:

sudo ./run 2023 --wrap-mode=respawn -- openssl s_client -connect imap.gmail.com:993
* OK Gimap ready for requests from ... 
But when I try to connect to the wss://localhost:2023 proxy I get the following:
127.0.0.1 - - [01/Aug/2014 17:00:02] 127.0.0.1: SSL/TLS (wss://) WebSocket connection
127.0.0.1 - - [01/Aug/2014 17:00:02] 127.0.0.1: Version hybi-13, base64: 'False'
127.0.0.1 - - [01/Aug/2014 17:00:02] connecting to command: 'openssl s_client -connect imap.gmail.com:993' (port 61000)
handler exception: [Errno 61] Connection refused 

I have the pem being used by websockify allowed on my system (I believe, I added it through mac os keychain). Do you know what I might be doing wrong?

Thanks so much again for your time!
-Duane

duane

unread,
Aug 1, 2014, 8:32:47 PM8/1/14
to no...@googlegroups.com
Sorry, I forgot to include the simpler case which was attempting to connect directly to the gmail imap server (rather than wrap openssl):

sudo ./run 2023 imap.gmail.com:993

WebSocket server settings:

  - Listen on :2023

  - Flash security policy server

  - SSL/TLS support

  - proxying from :2023 to imap.gmail.com:993


[ request made from browser through websock.js to wss://localhost:2023 ]


127.0.0.1 - - [01/Aug/2014 17:29:10] 127.0.0.1: SSL/TLS (wss://) WebSocket connection

127.0.0.1 - - [01/Aug/2014 17:29:10] 127.0.0.1: Version hybi-13, base64: 'False'

127.0.0.1 - - [01/Aug/2014 17:29:10] connecting to: imap.gmail.com:993

handler exception: [Errno 57] Socket is not connected

duane

unread,
Aug 1, 2014, 8:34:14 PM8/1/14
to no...@googlegroups.com
Ugh, reposting with better formatting:

sudo ./run 2023 imap.gmail.com:993
WebSocket server settings:
  - Listen on :2023
  - Flash security policy server
  - SSL/TLS support
  - proxying from :2023 to imap.gmail.com:993

[ request made from browser through websock.js to wss://localhost:2023 ]

127.0.0.1 - - [01/Aug/2014 17:29:10] 127.0.0.1: SSL/TLS (wss://) WebSocket connection
127.0.0.1 - - [01/Aug/2014 17:29:10] 127.0.0.1: Version hybi-13, base64: 'False'
127.0.0.1 - - [01/Aug/2014 17:29:10] connecting to: imap.gmail.com:993
handler exception: [Errno 57] Socket is not connected

Reply all
Reply to author
Forward
0 new messages