Websockets on Ionic


#1

Has anyone got websockets to work with ionic?

I have it all working using the websocket-rails gem in the browser. What are the barriers to this working in the simulator?

Websocket-rails is built on top of a Faye server. Everything is being initialized correctly and in the right order and I have double checked all the channel and “dispatcher” settings and they are the same as in the browser.

When I trigger a new message, the message is not getting to the server dedicated websockets controller and so there are no messages coming back.

var dispatcher = new WebSocketRails(WEBSOCKETS);
dispatcher.trigger('messages.create', $scope.message);

var channel = dispatcher.subscribe("chat_room_" + $scope.chat_room.id);
channel.bind('new_message', function(data) { 
  //DO STUFF
});

#2

It looks like recent versions of iOS should support websockets. Android maybe you have to add the plugin:

Although it works in the browser (chrome and safari), but I’m still having trouble in the emulator.


#3

Websocket support has nothing to do with Ionic. I’ve never setup sockets in an app before, but Ionic is not stopping you from doing so.


#4

Sorry, I saw you made a firebase implementation so I thought there might be some ionic stuff effecting websockets.


#5

Fixed! it was an SSL problem.


#6

Hi What was your issue with SSL?

Im trying to use Ionic with Socket.io.

The chat app works in the browser,but not on the mobile phone?

any help please


#7

NodeJS doesn’t run on the client. You can fallback to HTML5 websockets or Ajax calls to update data on your application.