     # keeps trying to connec the hangupsjs and communicates those
     # attempts to the client.
     reconnect = ->
+      console.log 'reconnecting', reconnectCount
       proxycheck().then ->
-        client.connect(creds)
+          client.connect(creds)
+          .then ->
+              console.log 'connected', reconnectCount
+              # on first connect, send init, after that only resync
+              if reconnectCount == 0
+                  sendInit()
+              else
+                  syncrecent()
+              reconnectCount++
+          .catch (e) -> console.log 'error connecting', e
 
     # counter for reconnects
     reconnectCount = 0

           {url:'https://plus.google.com', env:'HTTPS_PROXY'}
        ]
        Q.all todo.map (t) -> Q.Promise (rs) ->
            session = require('electron').session
            session.defaultSession.resolveProxy t.url, (proxyURL) ->
                # Format of proxyURL is either "DIRECT" or "PROXY 127.0.0.1:8888"
                [_, purl] = proxyURL.split ' '
                process.env[t.env] ?= if purl then "http://#{purl}" else ""

    mainWindow.on 'move',  (ev) -> ipcsend 'move', mainWindow.getPosition()

    # whenever it fails, we try again
    client.on 'connect_failed', (e) ->
        console.log 'connect_failed', e
        wait(3000).then -> reconnect()

    # when client requests (re-)init since the first init
