html5 - EventSource and Internet Explorer -


i have following server side play code in order provide endpoint html5 eventsources.

package controllers  import scala.util.matching import play.api.mvc._ import play.api.libs.json.jsvalue import play.api.libs.iteratee.{concurrent, enumeratee} import play.api.libs.eventsource import play.api.libs.concurrent.execution.implicits._  object application extends controller {    /** central hub distributing chat messages */   val (eventout, eventchannel) = concurrent.broadcast[jsvalue]    /** enumeratee filtering messages based on eventspec */   def filter(eventspec: string) = enumeratee.filter[jsvalue] {     json: jsvalue => ("(?i)" + eventspec).r.pattern.matcher((json \ "eventspec").as[string]).matches   }    /** enumeratee detecting disconnect of sse stream */   def conndeathwatch(addr: string): enumeratee[jsvalue, jsvalue] =      enumeratee.oniterateedone{ () => println(addr + " - sse disconnected") }    /** controller action serving activity based on eventspec */   def events = action { req =>     println(req.remoteaddress + " - connected , subscribed '" + eventspec +"'")     ok.feed(eventout       &> filter(eventspec)        &> concurrent.buffer(50)        &> conndeathwatch(req.remoteaddress)       &> eventsource()     ).as("text/event-stream").withheaders(       "access-control-allow-origin" -> "*",       "access-control-allow-methods" -> "get",       "access-control-allow-headers" -> "content-type"     )   }  } 

my routes that

get /events controllers.application.events

this server works fine when chrome browser attaching via eventsource object. since ie not support eventsources, using this polyfill library. problem: ie correctly subscribes events, see 'connected , subscribed' log output, event should passed connection, logs 'sse disconnected'. missing here? http headers?

it looks may using cors. (you're sending cors headers.) if so, may problem because polyfill using doesn't support cors. if need cors, can use this polyfill instead.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -