       @connected = false if message.successful
     
     # Initialize CometD 
-    cometURL = location.protocol + "//" + location.host + ":9876" + contextPath + "/cometd"
+    cometURL = location.protocol + "//" + location.hostname + ":9876" + contextPath + "/cometd"
     $.cometd.websocketEnabled = true
     $.cometd.init
       url: cometURL

        @finishExperiment_cb?()
    
  @subscribeExp: (channel) ->
    @expServiceSubscription = $.cometd.subscribe
      Codec.expSvcPrefix + channel, (message) => @serviceMessage_cb? message.data
    @expBroadcastSubscription = $.cometd.subscribe
      Codec.expChanPrefix + channel, (message) => @broadcastMessage_cb? message.data
    console.log "Subscribed to exp channels " + channel
    
  @subscribe: ->

  @init: (cookieName, contextPath) ->
    # Check for old state information
      
#    stateCookie = (if org.cometd.COOKIE then org.cometd.COOKIE.get(cookieName) else null)
#    state = (if stateCookie then org.cometd.JSON.fromJSON(stateCookie) else null)

    $.cometd.getExtension("reload").configure 
      cookieMaxAge: 10
    
