EzDevInfo.com

SocketRocket

A conforming Objective-C WebSocket client library.

Library not found Error when simple building web socket chat in iOS?

i downloaded simple web socket chat code and am getting this error

  ld: library not found for -lPods-SocketRocket
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Please anyone tell me how to solve this?

In my other linker flags contains these things

link

My code


Source: (StackOverflow)

clients for signalR in native ios and android

1) If I have to develop native IOS client for a server that uses SignalR can I use

SocketRocket or UnittWebSocketClient ?

2) The client App does not use any browser will that matter ?

3) How is SignalR Different from Superwebsocket or microsoft's websocket available in .net 4.5? Dont all of them support rfc6455 protocol ?


Source: (StackOverflow)

Advertisements

SocketRocket not working on iOS 5.0

I just made a simple real-time text chat application using SocketRocket. It works great on iOS 6.0 and 5.1 but when I try to run it on 5.0 when connecting I get the following error...

Websocket Failed With Error Error Domain=NSOSStatusErrorDomain Code=-9800 "The
operation couldn’t be completed. (OSStatus error -9800.)"
UserInfo=0x6e506e0 {}

Does anyone have any idea what this could mean or how to fix it? I browsed the issues on github but couldnt find anything and its claimed to work on iOS5+.

EDIT: To add, this is when I test on simulator. I dont have a device that has 5.0, so im not sure if fails on the phone in the same way. Also, if I use ws as opposed to wss (encrypted), it seems to work fine.


Source: (StackOverflow)

WebSocket Connection is not closing using SocketRocket

I use the SocketRocket library for Objective-C to connect to a websocket:

-(void)open {

if( self.webSocket ) {
    [self.webSocket close];
    self.webSocket.delegate = nil;
}

self.webSocket = [[SRWebSocket alloc] initWithURLRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"ws://192.168.0.254:5864"] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:20]];
self.webSocket.delegate = self;
[self.webSocket open];
}

Opening the connection works totally fine. The delegate is called after the connection was established.

-(void)webSocketDidOpen:(SRWebSocket *)webSocket {

NSLog(@"WebSocket is open");

}

But when I want to close the connection, nothing happens.

-(void)close {

if( !self.webSocket )
    return;

[self.webSocket close];
self.webSocket.delegate = nil;

}

The delegate for successfully closing the connection is not called. Can anyone tell me why this happens?

Thank you for reading my question.


Source: (StackOverflow)

Web Socket: cannot detect client connection on internet disconnect

I want to detect the client connection if client turn off the internet using web socket. My code is:

 //Include util library
    var util = require('util');
    // Include underscore library
    var _ = require('underscore')._;
    //For websocket
var webSocketServer = new (require('ws')).Server({port: (process.env.PORT || 5000)}),
webSockets = {} // userID: webSocket

// CONNECT /:userID
// wscat -c ws://localhost:5000/1
webSocketServer.on('connection', function (webSocket) 
{
  var userID = webSocket.upgradeReq.url.substr(1);
  //console.log('User_id is ',userID);
  webSockets[userID] = webSocket
                   util.log('User_id: [' + userID + '] enter in connected users list of [ ' + Object.getOwnPropertyNames(webSockets)+' ]')
                   // Call function which check id exist in letswalkee DB table
                   check_userid(userID);


                   // Send msg like: [fromUserID, text]    [1, "Hello, World!"]
webSocket.on('message', function(message) {
util.log('Received from [' + userID + ']: ' + message)
var messageArray = JSON.parse(message)
                                    var toUserWebSocket = webSockets[messageArray[0]]
                                    if (toUserWebSocket) {
                                    util.log('Sent to [' + messageArray[0] + ']: ' + JSON.stringify(messageArray))
                                    messageArray[0] = userID
                                    toUserWebSocket.send(JSON.stringify(messageArray))
                                    }
                                    })

                   webSocket.on('close', function () 
                   {
                      delete webSockets[userID]
                      util.log('User_id Deleted from connected users: [ ' + userID+' ]');

                    })
webSocket.on('disconnect',function()
  {
   console.log('hello i am disconnected');  
  });
})

I used that code (webSocket.on('disconnect',function()) but did not worked? Help asap?


Source: (StackOverflow)

Implementin SRWebSocketDelegate in Swift

I am implementing:

@protocol SRWebSocketDelegate <NSObject>

- (void)webSocket:(SRWebSocket *)webSocket didReceiveMessage:(id)message;

@optional

- (void)webSocketDidOpen:(SRWebSocket *)webSocket;
- (void)webSocket:(SRWebSocket *)webSocket didFailWithError:(NSError *)error;
- (void)webSocket:(SRWebSocket *)webSocket didCloseWithCode:(NSInteger)code reason:(NSString *)reason wasClean:(BOOL)wasClean;

in Swift. All functions I can implement ok and works, but didCloseWithCode I just can't make it to work.

I am having trouble implementing

- (void)webSocket:(SRWebSocket *)webSocket didCloseWithCode:(NSInteger)code reason:(NSString *)reason wasClean:(BOOL)wasClean;

in Swift.

I am trying:

func webSocket(webSocket: SRWebSocket!, didCloseWithCode code: NSInteger!, reason: NSString!, wasClean: Bool!) {
    println("websocket closed: \(reason)")
    self.connect(5.0)
}

with no luck.


Source: (StackOverflow)

Why does my websocket server always report [websocket: control frame length > 125]?

My iOS application uses SocketRocket to establish a connection with my websocket server. But after establishing a connection and sending the first message, the server (using gorilla/websocket) tries to parse the frame, but failed:

message_type, r, err := ws.NextReader()
if err != nil {
    goto end
}

An error is reported when calling NextReader():

Websocket Read Failed: [websocket: control frame length > 125]

The strange thing is, I use SocketRocket's send() method to send data, so there should never be any control frames (ping/pong).

Has anyone seen this problem before? Help!


Source: (StackOverflow)

How to create a CocoaPod with nested git submodules?

I'm trying to create a CocoaPod with nested git submodules. I can create the pod, however, I can't fully install it.

When I run pod install --verbose I can see that git submodule update --init is being run instead of git submodule update --init --recursive which doesn't pull the nested submodule.

Does CocoaPods support nested submodules, or no? I have scoured the web for potential leads, but can't find anything!

I should also mention that I that lint passes with pod lib lint but not pod spec lint. pod spec lint complains that it can't find the header file in the nested submodule. I'm not sure if this is related to the problem above.

(Also note that this particular Pod I'm working on is only a proof of concept. I'll be creating a much more complex Pod that depends on socket.IO-objc. Unfortunately socket.IO-objc is not available as a Pod, and depends on SocketRocket as a submodule.)

Here's my PodSpec:

Pod::Spec.new do |s|
  s.name             = "DebugTools"
  s.version          = "0.1.0"
  s.summary          = "Awesome tools for debugging iOS apps."
  s.homepage         = "https://github.com/robertcrabtree/DebugTools"
  s.license          = 'MIT'
  s.author           = { "Robert Crabtree" => "me@gmail.com" }
  s.source           = { :git => "https://github.com/robertcrabtree/DebugTools.git", :tag => s.version.to_s, :submodules => true }

  s.platform     = :ios, '7.0'
  s.requires_arc = true

  s.source_files = 'Pod/Classes/**/*', 'Pod/Submodules/LogMaster/LogMaster/*.{h,m}', 'Pod/Submodules/LogMaster/LogMaster/LogCore/*.h'
  s.resource_bundles = {
    'DebugTools' => ['Pod/Assets/*.png']
  }
end

Here's my Podfile:

pod "DebugTools", :git => "https://github.com/robertcrabtree/DebugTools.git", :submodules => true

Source: (StackOverflow)

iOS Client connecting to NodeJS socket.io results in Stream end encountered

I have a NodeJS server that uses socket.io and listen to port 8000. The code is something like this:

var io = require("socket.io");
var socket = io.listen(8000);
...
socket.sockets.on("connection", function(client) {
    util.log("Client connects: " + client.id);
});  

I have written a web client that can connects to this server and it works just fine. So the server code is not the problem. The problem is with the iOS client that I am about to describe next.

The iOS client uses SocketRocket and to install it, I use Cocoapods and have a Podfile with the following:

platform :ios
pod 'SocketRocket', '0.2.0'

In MyViewController.h

#import <SocketRocket/SRWebSocket.h>

@interface MyViewController : UIViewController<SRWebSocketDelegate> 
    ...
    @property (strong, nonatomic) SRWebSocket *socket;
@end

In MyViewController.m

@synthesize socket = _socket;
...

- (void)viewDidLoad
{
    _socket = [[SRWebSocket alloc] initWithURLRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://127.0.0.1:8000"]]];
    _socket.delegate = self;

    [_socket open];

    NSLog(@"Connect");
}

- (void)webSocket:(SRWebSocket *)webSocket didReceiveMessage:(id)message {
    NSLog(@"Error didReceiveMessage");
}

- (void)webSocket:(SRWebSocket *)webSocket didFailWithError:(NSError *)error {
    NSLog(@"Error connecting websocket");
}

- (void)webSocket:(SRWebSocket *)webSocket didCloseWithCode:(NSInteger)code reason:(NSString *)reason wasClean:(BOOL)wasClean {
    NSLog(@"Error didCloseWithCode %d: %@", code, reason);
}

When the iOS client runs, the log "Connect" shows up. But the delegate didCloseWithCode() also gets invoked. And the log shows

Error didCloseWithCode 0: Stream end encountered

I have spent lots of time trying to figure out, but it's time to get some help from experts. Why am I getting the "Stream end" problem. The NodeJS server is working just fine, since I can connect to it with a web client. What am I doing wrong with the iOS client and how can I correct?

Update: Add JavaScript code on the server to show the util.log() call. When the web client connects, console shows "Client connects"..." message. When the iOS client attempts to connect, nothing on the console.


Source: (StackOverflow)

.framework product is red no matter what

I'm trying to add this framework to a project. I have followed these instructions to the letter:

  1. Add SocketRocket.xcodeproj as either a subproject of your app or in your workspace.
  2. Add SocketRocket.framework to the link libraries
  3. If you don't have a "copy files" step for Framework, create one
  4. Add SocketRocket.framework to the "copy files" step.

I made sure I had only one instance of xcode open, then dragged the SocketRocket.xcodeproj file into my project. I added the .framework file to the link libraries, created a copy files build phase, then added the .framework to the copy files build phase.

This is the error I get when I try to build:

clang: error: no such file or directory: '/Users/adamhickey/Library/Developer/Xcode/DerivedData/websockettest-fcuhfltporfkitgubwcjukxogzas/Build/Products/Debug-iphonesimulator/SocketRocket/SocketRocket'

It's quite right: that directory does not exist.

In build phases, the SocketRocket.framework is red under Link Binary With Libraries. It's also red in the products folder of the SocketRocket subproject.

I've been googling this error for hours and the majority of the things I've tried have pointed me towards changing the build location in Xcode->preferences-locations. I've tried:

  1. setting it to relative, picking my own, and going to advanced and choosing legacy.
  2. building for a device
  3. build for->archiving
  4. building for release

If I open the SocketRocket.xcodeproj in a separate instance of xcode and try to build it, 3 of the four products are red. The products are: libSocketRocket.a, SRWebSocketTests.octest, TestChat.app, and SocketRocket.framework. The first is white, while the last three are red.

I'm assuming that if I can get the .framework file to build in a separate project, this will solve my overall problem. However, nothing I do seems to have any effect.

Please please please help! I'm using xcode 4.6.


Source: (StackOverflow)

Error in opening .xcworkspace

I integrated pods in my project specifically SignalR, AFNetworking and SocketRocket. It was successfully installed, but when I opened .xcworkspace, this error shows:

enter image description here

This is what the project navigator looks like

Has anyone encountered this kind of error? Thanks in advance.

Update: My .xcodeproj has appeared. But the frameworks appear red. How can I solve this?

enter image description here


Source: (StackOverflow)

Class is implemented in both. One of the two will be used

I have a project that has a dependency (installed via CocoaPods) using SocketRocket and have imported a static library from HeapAnalytics. Apparently the HeapAnalytics library already uses SocketRocket. I get no errors when compiling, but at runtime receive the following:

Class SRWebSocket is implemented in both [path] and [path].
One of the two will be used. Which one is undefined.

I'm not sure how to handle it because most solutions I've seen require compiling the static library yourself change class names and such, and I don't have access to the source.

Any recommendations?


Source: (StackOverflow)

iOS Client connecting to server using socketrocket results in "Stream end encountered"

NSString *urlString = @"ip address";
self.webSocket = [[SRWebSocket alloc] initWithURLRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urlString]]];
self.webSocket.delegate = self;
[self.webSocket open];

Here didCloseWithCode is called with reason Stream end encountered.

Any ideas about what might go wrong?


Source: (StackOverflow)

SocketRocket (iOS) : How to identify whom user are chatting with another?

I would like to create multiple sockets between all users. So how can i pass key and ID such as the server is divided in seprated windows.

Thank You.


Source: (StackOverflow)

iOS - Best solution for implementing websocket connection across the entire iOS app?

In my app, websocket connection and communication is in the certain ViewController but later came request to receive messages through websocket across the entire app.

What would be the best way to do it? To move the websocket code to AppDelegate or to create super ViewController? Or something else and better?


Source: (StackOverflow)