martijnwalraven / meteor-ios

Meteor iOS integrates native iOS apps with the Meteor platform (http://www.meteor.com) through DDP
MIT License
740 stars 79 forks source link

Open web socket to continue sending message, Connecting App running on simulator to local server running on macbook #87

Open Abhisheksnapwiz opened 8 years ago

Abhisheksnapwiz commented 8 years ago

when ever i am trying to connect to my local running server using simulator i am not able to connect. for connection i am using "ws://MyLocalIP:4000:/websocket" and also "ws://127.0.0.1:4000:/websocket" url. can we connect simulator to local running server? please give me some solution.

when i am using direct server url it is working but there is one issue is that some times it connecting and some times it getting crash by saying this reason: 'Attempting to send message without an open connection' how to handle this crash? because meteor-ios framework always checking for web socket is open or not to send message and if it found that web socket is not open then it is getting crash while sending message in this method of this line. inside - (void)sendMessage:(NSDictionary *)message { getting crash at this line NSAssert(self.open, @"Attempting to send message without an open connection") How to handle this crash ?

Please give some solution as soon as possible. waiting for your valuable response.

Thanks

martijnwalraven commented 8 years ago

I'm not sure if this is a type in this message or your code, but ws://MyLocalIP:4000:/websocket is not a valid URL. You'll have to remove the colon after the port number: ws://MyLocalIP:4000/websocket.

Abhisheksnapwiz commented 8 years ago

Here MyLocalIP is my current IP ws://MyLocalIP:4000:/websocket and my local server is running and message showing in terminal is App running at: http://localhost:4000/ but i am not able to connect to local server from my simulator. can we connect simulator to local server.

_And also major problem is _

when it is connecting to remote server there is one issue is that some times it connecting and some times it getting crash by saying this reason: 'Attempting to send message without an open connection' how to handle this crash? because meteor-ios framework always checking for web socket is open or not to send message and if it found that web socket is not open then it is getting crash while sending message . inside - (void)sendMessage:(NSDictionary *)message { getting crash at this line NSAssert(self.open, @"Attempting to send message without an open connection") How to handle this crash ?

Thank you for your response :+1: can you please give me some solution How to handle this crash ?

martijnwalraven commented 8 years ago

I understand MyLocalIP is your current IP, but you've again included an extra colon in the URL. Is that what you're also doing in code? Because that would explain your issue.

The web socket disconnecting may have to do with an issue with compression that was fixed in 0.2.1. Are you using the latest version?

Abhisheksnapwiz commented 8 years ago

Sorry it is typing mistake during posting you- url is "ws://MyLocalIP:4000/websocket" and it's not working just now i update my pod it is showing Using Meteor (0.2) but as you told latest version is 0.2.1 why?

Abhisheksnapwiz commented 8 years ago

Please find the screen shot and message of crash while sending message to web socket.

i want to conform one thing that can we connect local server running on my mac to app running in simulator. If yes then why i am not able to connect plz suggest me.

screen shot 2016-04-06 at 7 30 13 pm

Assertion failure in -[METDDPConnection sendMessage:] *\ Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Attempting to send message without an open connection'

Abhisheksnapwiz commented 8 years ago

Thanks ...By adding new version " 0.2.1", I am able to connect my simulator with local server which is running on my macbook .:+1:

But Still some times i am getting crash by saying this message

Assertion failure in -[METDDPConnection sendMessage:] *\ Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Attempting to send message without an open connection'

you can find image in above comment. can you please suggest how can i handle this crash. This crash is happening even if app is running and connection is established but while sending message to web socket if socket is unfortunately not open or got close then app is getting crash. please provide some solution to handle this crash.