# Ember data and Websockets / SockJS

**URL:** <https://discuss.emberjs.com/t/ember-data-and-websockets-sockjs/5516>\
**Category:** Ember Data\
**Created:** [June 3, 2014, 9:19pm UTC](https://discuss.emberjs.com/t/ember-data-and-websockets-sockjs/5516 "2014-06-03T21:19:08Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hummingbird](https://avatars.discourse-cdn.com/v4/letter/h/59ef9b/32.png) [@Hummingbird](https://discuss.emberjs.com/u/Hummingbird)\
**Post date:** [June 3, 2014, 9:19pm UTC](https://discuss.emberjs.com/t/ember-data-and-websockets-sockjs/5516/1 "2014-06-03T21:19:08Z")

</div>

After much thinking about which route I would like to go when refactoring a web application which previously used server side rendering, I now almost came to the conclusion that I want to handle all my connections via websockets. Not just for the fun of it, but I can see some very tempting advances of how to get all the needed data to the client. Unfortunately I haven’t found much information about how ember data plays together with websockets. Preferably I would like to use SockJS which offers fallback solutions in case the websocket can not be established. Secondly I would like to refactor the backend to use vertx, which in terms provides a full server side SockJS implementation [2].

I have found one or two custom implementations of adapters to use websockets like [1], but currently nothing to use SockJS. Has anyone already tried to accomplish that? If not I would really like to give that a try, but I am pretty new to ember and the whole websocket thing, so any pointers where to start are much welcome.

[1] [https://gist.github.com/carlwoodward/8659793](https://gist.github.com/carlwoodward/8659793) [2] [http://vertx.io/core\_manual\_groovy.html#sockjs](http://vertx.io/core_manual_groovy.html#sockjs)

---

<div class="post-metadata">

**Author:** ![ulisesrmzroche](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/ulisesrmzroche/32/11317_2.png) [@ulisesrmzroche](https://discuss.emberjs.com/u/ulisesrmzroche)\
**Post date:** [June 3, 2014, 10:11pm UTC](https://discuss.emberjs.com/t/ember-data-and-websockets-sockjs/5516/2 "2014-06-03T22:11:24Z")

</div>

> **[Pushing Records into the Store - Ember Data - Ember Guides](https://guides.emberjs.com/release/models/pushing-records-into-the-store/)**
>
> One way to think about the store is as a cache of all of the records that have been loaded by your application. If a route or a controller in your app asks for a record, the store can return it immediately if it is in the cache. Otherwise, the store...

---

<div class="post-metadata">

**Author:** ![pixelhandler](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/pixelhandler/32/18649_2.png) [@pixelhandler](https://discuss.emberjs.com/u/pixelhandler)\
**Post date:** [June 3, 2014, 10:15pm UTC](https://discuss.emberjs.com/t/ember-data-and-websockets-sockjs/5516/3 "2014-06-03T22:15:51Z")

</div>

@Hummingbird I’ve experimented with a SocketSource using Orbit.js to use a socket for resources (data w/ json payloads) rather than using the socket only for sending messages. Here are some of my discoveries so far: [https://gist.github.com/pixelhandler/5389c72c82d26fae8fb1](https://gist.github.com/pixelhandler/5389c72c82d26fae8fb1) once the ember-orbit project is released, I’ll finish up the SocketSource (addition for Orbit.js) to use with that library.

---

<div class="post-metadata">

**Author:** ![Hummingbird](https://avatars.discourse-cdn.com/v4/letter/h/59ef9b/32.png) [@Hummingbird](https://discuss.emberjs.com/u/Hummingbird)\
**Post date:** [June 4, 2014, 5:23pm UTC](https://discuss.emberjs.com/t/ember-data-and-websockets-sockjs/5516/4 "2014-06-04T17:23:26Z")

</div>

Thanks, i have already seen that. However if I understand that correctly I would still need to write an adapter in order to query for a required set of data?

---

<div class="post-metadata">

**Author:** ![Hummingbird](https://avatars.discourse-cdn.com/v4/letter/h/59ef9b/32.png) [@Hummingbird](https://discuss.emberjs.com/u/Hummingbird)\
**Post date:** [June 4, 2014, 5:27pm UTC](https://discuss.emberjs.com/t/ember-data-and-websockets-sockjs/5516/5 "2014-06-04T17:27:16Z")

</div>

Thanks, that is quite interesting. However it seems you did not give any answer to the question why you did not use ember data, unless I overlooked it. Has it just been at a too early stage or are there any other reasons why this hasn’t been feasible?

---

<div class="post-metadata">

**Author:** ![ulisesrmzroche](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/ulisesrmzroche/32/11317_2.png) [@ulisesrmzroche](https://discuss.emberjs.com/u/ulisesrmzroche)\
**Post date:** [June 4, 2014, 7:24pm UTC](https://discuss.emberjs.com/t/ember-data-and-websockets-sockjs/5516/6 "2014-06-04T19:24:45Z")

</div>

yup, unless someone already came out with one. It shouldn’t be too hard to write though.

---

<div class="post-metadata">

**Author:** ![pixelhandler](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/pixelhandler/32/18649_2.png) [@pixelhandler](https://discuss.emberjs.com/u/pixelhandler)\
**Post date:** [June 4, 2014, 7:35pm UTC](https://discuss.emberjs.com/t/ember-data-and-websockets-sockjs/5516/7 "2014-06-04T19:35:34Z")

</div>

@Hummingbird I wasn’t interested in writing a socket adapter for Ember Data as I was more interested in a store that has transactions between multiple stores, e.g. memory, localStorage, remote DB via web socket.

---

<div class="post-metadata">

**Author:** ![Hummingbird](https://avatars.discourse-cdn.com/v4/letter/h/59ef9b/32.png) [@Hummingbird](https://discuss.emberjs.com/u/Hummingbird)\
**Post date:** [June 4, 2014, 7:41pm UTC](https://discuss.emberjs.com/t/ember-data-and-websockets-sockjs/5516/8 "2014-06-04T19:41:17Z")

</div>

Thanks, awesome. I think that’s all I needed to know for now 🙂
