mondora / asteroid

An alternative client for a Meteor backend
MIT License
734 stars 101 forks source link

Installing app on Android error (Ionic Framework)? #44

Open brunodb3 opened 9 years ago

brunodb3 commented 9 years ago

(Sorry if i don't mark this as a question, i'm new here) By the way, i find that Asteroid is amazing! Good job! So, i am currently developing a Ionic Framework App (Android), to communicate with a Meteor App (with it's own server), and i managed to succeed when testing in the browser (Google Chrome), but when i installed the app on a real Android device, it gave me an error...

WebSocket connection to 'ws://my.meteor.app.server' failed: Error during WebSocket handshake: Status line does not end with CRLF

It shows me that the error is on ddp.js, line 62. I have tried some things, like adding '\r' to the end of some variables, but i don't quite understand this WebSocket thing... Is there anyway someone can help me?

pscanf commented 9 years ago

Hello there,

I'm afraid I don't have enough elements to pinpoint exactly what the problem is, but if I'd have to guess, I'd blame the android browser support for websockets (it may not be properly implemented).

Try to include in your app the sock.js library and see if it solves the problem (it would allow to fallback to http long polling).

If it doesn't solve the issue, share the code that's causing it if you can. Otherwise we can schedule a hangout to try to figure it out. :smiley:

Let me know Cheers!

pscanf commented 9 years ago

P.S. - don't worry about the labels thing. I was trying to label some issues as questions to transform them into "alternative documentation", but I'm not sure whether it's a good idea. :smiley:

brunodb3 commented 9 years ago

Thank you for the reply Paolo, i have tried using the sock.js already, but i didn't succeed in 'configuring' it on the server-side. I installed the Phonegap plugin on the Ionic app, but with no success either. I am currently trying to use the socket.io library, but now my error is on CORS, wich i can't configure in the server-side to accept my connection... Let me try to explain what i'm trying to do here...

1st - I want a Meteor application (in this case, it's running on the Cloud9 IDE, for lack of convenience) with its own server, MongoDB as a database, right?

2nd - I want a Ionic (Cordova/Phonegap) application for Android to connect with that Meteor app via DDP, or any other way i can manipulate the database with, either by calling methods on the Meteor side, or using your Asteroid library.

3rd - I want my .NET application to do the same thing the Ionic one does, connect via DDP or anything else i will be able to manipulate data.

The Meteor app is going to act more like a server than a client... What i really need is the intercommunication with the .NET and Ionic apps. And a database on the cloud. I tried a lot of alternatives, but i think that in this way, it will be easier for me, as i'm not quite an expert on programming actually. I have an idea too, but i don't know if it's best... It would be like, make a Meteor app, like a website really. Host it, and then on the Ionic and .NET apps, i make like a WebView or something, to access that website... But i don't know if it would work pretty well... Anyway, i'm open for suggestions :-)

P.S. - Yes, i am the one who sent you an email about the promise thing on the login method, cause i really don't know how to get that 'callback' (the message that the login method returns) and display it on the client.

P.P.S (or P.S.S, i don't know) - As of a hangout, it could be a possibility, but it would have to be on a weekend, as most of the time i'm working... If you want, we could have one this Saturday, if i can't figure out anything by then.

Thank you so much Paolo, and sorry if i didn't make myself clear, my english is not the best ;-)

brunodb3 commented 9 years ago

I found a 'angularDDP' library (https://github.com/afuggini/angular-ddp), been trying to use it, since SockJS was not a success (it uses HTTP, and i couldn't enable the 'Allow-Cross-Origin-Request' thingy on my server (the Meteor app)... But now, i can't use this new library either, it is kinda 'incomplete'. It says that the $q module is not avaiable... I'm stuck in this DDP thing for almost 3 days now, why does it work fine in the browser, but when i go to mobile it gives me a CRLF error??

brunodb3 commented 9 years ago

If you want to see a bit of code, i asked the same question on StackOverflow. Here's the link:

http://stackoverflow.com/questions/28455004/websocket-handshake-error-on-ionic-app-status-line-does-not-end-with-crlf

andreasbhansen commented 9 years ago

@brunodb3 Did you ever manage to solve this?

polacekpavel commented 9 years ago

@andreasbhansen I've similar issue. I can't get work this with Ionic framework...But after I've included SockJS

 <script src="lib/sockjs/sockjs-1.0.0.min"></script>

and add Crosswalk support

ionic browser add crosswalk

Everything works same as in browser emulator.

Hope it helps

andreasbhansen commented 9 years ago

Thanks, @polacekpavel.

I’ll try that :-)

kfatehi commented 9 years ago

For the record, I'm using asteroid in ionic successfully. Are you sure you're correctly defining which server to connect to?

pavanputhra commented 9 years ago

Had same problem. Did following to fix it.

bower install sockjs-client --save

Added following to index.html, at top

<script src="lib/sockjs-client/dist/sockjs-1.0.3.min.js"></script>
pavanputhra commented 8 years ago

I did some experiment and found out the cause for this. In some hosting environment WebSocket is disabled. For example, in my case, my test server was behind CloudeFlare proxy, so WebSocket won't work with it. Hence Asteroid had to fall back to SockJs. For this reason including it solved the problem.