w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
WebSocket handshake with Ruby and EM::WebSocket::Server
1) I think that once the connection is open the request and response have already occurred, so sending headers at that point is too late. In addition, headers have to end with a blank line, which you omitted. 2) According to the demos, you don't even have to set headers in the client or the server--the ruby module automatically takes care of the headers on the server side, and html5 automatically takes care of the headers on the client side. I think this should work: require "em-websocket-server" class EchoServer < EM::WebSocket::Server def on_connect EM::WebSocket::Log.debug "Connected" puts "I felt a connection." end def on_receive msg puts "RECEIVED: #{msg}" send_message msg end end EM.run do myhost = "0.0.0.0" myport = 8000 puts "Starting WebSo

Categories : Javascript

how to remove +universal
Just remove the line containing +universal from variants.conf (or clear out variants.conf completely) and skip this step of the how-to. It is no longer needed, MacPorts will automatically ensure the dependencies are available in the correct architecture when you attempt to install wine.

Categories : Misc

Using Universal ImageLoader
You need to add the jar to the libs folder and not to the lib. If you add it manually to the lib folder, then go to: -> Java Build Path -> Order and Export and there select the jar

Categories : Android

Universal value for dictionary
You could use the StructLayout(LayoutKind.Explicit) and FieldOffset attributes to create equivalent functionality. I'll assume that you meant a 64-bit data structure, which would contain 8 bytes or 2 ints. If you really did mean a 64-byte data structure, you would need to define a struct with 64 bytes and 16 ints. (Probably better to use a byte[] and a int[].) You can find information here: http://winfx.msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_csref/html/163ab9b5-46f6-4d78-9025-f7bbba89b2e1.asp For instance: using System.Runtime.InteropServices; [StructLayout(LayoutKind.Explicit)] struct ByteArray { [FieldOffset(0)] public byte Byte1; [FieldOffset(1)] public byte Byte2; [FieldOffset(2)] public byte Byte3; [FieldOffset(3)] public byte Byte4; [FieldOf

Categories : C#

Jetty WebSocket
The java.lang.NullPointerException at org.eclipse.jetty.websocket.WebSocketFactory.upgrade(WebSocketFactory.java:238) means you either ... Attempted to use the Jetty WebSocket code from a non-Jetty server (such as Tomcat). Or you attempted to upgrade from a non HTTP connection (such as SPDY). This is because the core HTTP connection cannot be found during the the Upgrade process of the WebSocket handshake, which is a requirement for that Jetty WebSocket server code to function.

Categories : Java

WebSocket app architecture
This is not easy to answer generally, for it depends on your specific setup. However, here are my thoughts on this: I think option 2 is the better approach, because open connections are really a limited resource for many webservers. Remember, that a websocket connection is different from a regular http request and stays open over a long time. The additional complexity of the multiplexing protocol is really not an issue I think. All implementations I know of websocket communication protocols use the latter approach, although I must admit to not know really many examples.

Categories : Java

Websocket opcode 7 with wss
The error message is confusing, since opcode 7 is indeed reserved (http://tools.ietf.org/html/rfc6455#section-5.2), but it also mentions RSV1 which is also reserved, but gives no observed value Did you try Chrome or IE10? You could also try running AutobahnTestsuite against your node server. The testsuite has a fuzzingclient mode that supports WSS. The testsuite includes extensive wire log reports which might help finding out what happens. Disclosure: I am original author of Autobahn and work for Tavendo.

Categories : Node Js

Websocket complications
OK... you have a few questions, so I will try to answer them one by one. 1. What to use You could use Socket.IO. Its a library for developing realtime web application based on JavaScript. It consists of 2 parts - client side (runs on the visitor browser) and server side. Basic usage does not require almost any background knowledge on Node.js. Here is an example tutorial for a simple chat app on the official Socket.IO website. 2. Hosting Most of the hosting providers have control panel (cPanel) with the capebility to install/activate different Apache plugins and so on. First you should check if Node.js isn't available already, if not you could contact support and ask them if including this would be an option. If you don't have any luck with your current hosting provider you could alwa

Categories : PHP

iOS Universal App - UITableView/UICollectionView
When you are talking about code reuse you probably mean the DRY principle. It just says you should not write the same code or the same information twice, but I don't think this is your main issue here. I would use a UITableViewController on the iPhone and a UICollectionViewController on the iPad. I think this is the cleanest and easiest way to go. What exactly do you hope to reuse among both controllers? The both require two different delegate protocols, so most of the methods will be specific to one platform. You will need two NSFetchedResultsController if you're using Core Data, but reusing the fetched results controller code only makes sense if you need the same data on both platforms. If you create a new universal project in Xcode you will get a basic project setup that looks differe

Categories : IOS

How to use universal oauth redirect url?
If you want to get data from the you tube then why you are use google api? you can you you tube api and get data you want it... https://developers.google.com/youtube/

Categories : PHP

Creating a universal spoiler box
It sounds like you are just needing to use classes, rather than an id. Using id's is generally not necessary or recommended. $(document).ready(function(){ $(".spoil").click(function(){ //bind a click function to all elements with class "spoil" $(this).toggle(); }); });

Categories : Javascript

How do I make my app universal? (3.5", 4", and iPad)
To initialize storyboard: CGSize iOSDeviceScreenSize = [[UIScreen mainScreen] bounds].size; UIViewController *initialViewController; if (iOSDeviceScreenSize.height == 480) { // Instantiate a new storyboard object using the storyboard file named Storyboard_iPhone35 UIStoryboard *iPhone35Storyboard = [UIStoryboard storyboardWithName:@"iPhone4" bundle:nil]; // Instantiate the initial view controller object from the storyboard initialViewController = [iPhone35Storyboard instantiateInitialViewController]; } if (iOSDeviceScreenSize.height == 568) { // iPhone 5 and iPod Touch 5th generation: 4 inch screen // Instantiate a new storyboard object using the storyboard file named Storyboard_iPhone4 UIStoryboard *iPhone4Storyboard = [UIStoryboard storyboardWithName:@"

Categories : Iphone

Synchronous Universal Analytics
Use this one: <script src="//www.google-analytics.com/analytics.js"></script> <script> var tracker = ga.create('UA-12345678-1', 'auto'); tracker.send('pageview'); </script> Tested.

Categories : Javascript

Using the Universal Chess Interface
Let's assume the GUI is facilitating a match between a human user and an engine. Let's say the user starts with e2e4. Then the commands would look something like: // GUI: tell the engine to use the UCI protocol uci // ENGINE: identify id name Chess Engine id author John Smith // ENGINE: send the options that can be changed // in this case the hash size can have a value from 1 to 128 MB option name Hash type spin default 1 min 1 max 128 // ENGINE: sent all parameters and is ready uciok // GUI: set hash to 32 MB setoption name Hash value 32 // GUI: waiting for the engine to finish initializing isready // ENGINE: finished setting up the internal values and is ready to start readyok // GUI: let the engine know if starting a new game ucinewgame // GUI: tell the engine the po

Categories : Linux

Universal references and std::initializer_list
Here's the crux: Deducing a type from a braced-init-list ({expr...}) doesn't work for template arguments, only auto. With template arguments, you get a deduction failure, and the overload is removed from consideration. This leads to the first and third output. it does even matter whether one takes the initializer_list by value or by const& foo: For any X, two overloads taking X and X& parameters are ambiguous for an lvalue argument - both are equally viable (same for X vs X&& for rvalues). struct X{}; void f(X); void f(X&); X x; f(x); // error: ambiguous overloads However, partial ordering rules step in here (§14.5.6.2), and the function taking a generic std::initializer_list is more specialized than the generic one taking anything. goo: For two overloads wit

Categories : C++

Universal path to chrome.exe
Chrome installs by default to the User's AppData Local folder: XP: C:Documents and SettingsUserNameLocal SettingsApplication DataGoogleChrome Vista: C:UsersUserNameAppDataLocalGoogleChrome Windows 7: C:UsersUsernameAppDataLocalGoogle Update: As mentioned in a comment, it appears the path to chrome.exe has changed in Win7/8. It's now in: C:Program Files (x86)GoogleApplicationchrome.exe Best bet is to use some OS detection code, then use an environment variable to detect the User's AppData folder (i.e. %LOCALAPPDATA%) or the ProgramFiles folder, and then append the difference in OS's to the end of the variable.

Categories : Google Chrome

Universal message broker
Assuming you have the ability to manage the server configuration, why not have the separate process generate log entries via syslog, then use a simple server-side script to examine the log entries thus generated, and present them in the browser in whatever fashion you find most useful? Syslog already is a "universal message broker", after all, and it's almost always easier to make use of an existing capability than to develop a new one from scratch. Unfortunately, I'm unable to present a really specific answer, because you haven't identified the server-side language you're using; if you'll edit your question to include that information, and comment on my answer to let me know you've done so, I'll see what I can come up with to give you a real start on solving the problem.

Categories : Misc

nodejs as websocket client
Socket.io (which is probably what you'll want to use server-side) has a client module that works in node. It handles maintaining a connection to the server. What you'll probably want to do is not push the image itself over the WebSocket connection. Instead, send a "new image available" notification message over the WebSocket, and when the client receives the message, make a regular HTTP GET request to the server to download the image. Since you're making a regular HTTP request, you can use the Range header if you need to resume an interrupted download.

Categories : Node Js

JQuery deferred and websocket
I would use Async.js https://github.com/caolan/async. A great library for making asynchronous requests and working with the results when they come in. For your case you could use Async.parallel, which would fire both requests off and call the callback when both results are in (in a results array). Alternatively, if you didn't want to use a library, you could cache the results from each ajax call, then run a check each time a call returned to make sure you only construct your html once both calls have completed: have a callback that checks the size of a results array pass this as the callback to both ajax requests when results array size is 2 (or number of requests you've made) run the html construction code

Categories : Jquery

Using go-websocket behind Apache mod_proxy_wstunnel
Thanks everyone! After taking several advices above, I found the solution. And for someone who might have similar issue, here is the solution to my question: As Aralo suggested, trailing slash must be added to the WebSocket path (in my case: "/ws/"). It looks Apache will only handle WebSocket with a valid GET request. James Henstridge was right. The order of ProxyPass relevant. ProxyPass of /ws/ must be put before the / line. After consulting the Chat example code, I found an origin check in the function ServeWs() and removed. Everything works now. And thanks covener, reading logs does help.

Categories : Apache

HTTP Kit WebSocket client
There is no Websocket client support yet but there is a feature request to add client support that you could weigh in on: https://github.com/http-kit/http-kit/issues/69

Categories : Clojure

error while using Django-websocket
Well, I downloaded their entire code (not pip install) and run the supplied example chat program. Same error. The system sends a 400 response code for any ws:// call. The git hub project page linked on the pypi site returns a 404 error. No way I can file a bug report. Emailed the developer and didn't get any response. Probably something should have been broken on the new Django 1.5.2 version. I consider that this is a dead project and hence moving to a complex but working solution like gevent or twisted. thanks for your support!!!

Categories : Python

Netty and SSL websocket client
I seem to have found a solution to my own question. The sample code on the client uses the channel.write() method, which seems not to send the messages to the Websocket ssl server. By using the channel.writeAndFlush() instead, messages are correctly sent to the server.

Categories : Ssl

How retrieve data from websocket?
You may need to use JSON.stringify before emiting the data variable like io.sockets.emit('update chat' , 'username':socket.username , 'data':JSON.stringify(data)); and parse same string back to json form at recieving end via JSON.parse like var objData = JSON.parse(data);

Categories : Android

How to get an existing websocket instance
The container creates a separate instance of the endpoint for every client connection, so you can't do what you're trying to do. But I think what you're trying to do is send a message to all the active client connections when an event occurs, which is fairly straightforward. The javax.websocket.Session class has the getBasicRemote method to retrieve a RemoteEndpoint.Basic instance that represents the endpoint associated with that session. You can retrieve all the open sessions by calling Session.getOpenSessions(), then iterate through them. The loop will send each client connection a message. Here's a simple example: @ServerEndpoint("/myendpoint") public class MyEndpoint { @OnMessage public void onMessage(Session session, String message) { try { for (Session s : session.

Categories : Java

Can't get AutoBahn Websocket to Connect
Web browser do fill the origin field and disallow any JavaScript from manipulating origin. For non-browser WebSocket clients, the client can set origin as it likes. Hence origin cannot be trusted by the WebSocket server. The presence of origin is not required by the WebSocket spec, and setting is currently not supported by AutobahnAndroid.

Categories : Android

Very simple websocket in node.js
I too have a small nit-picking issue with the ws module. They do not delete the socket object data after closing and it becomes a nuisance because all of data is then pushed into memory and it becomes a memory leak UNTIL the V8 Garbage Collector deletes the unused data. It's fine in 1 sense, but if you have a gameserver, or a VERY active game where people are refreshing/joining channels/games/etc, that extra overhead adds quite a bit of unnecessary memory usage. I believe the ws module would work best if they could delete the temporary socket object properties upon closing instead of waiting for the V8 GC to. With that said, it's a minimal amount of data and the average user won't even notice it unless they have a very active server. In any event, take a look at this gem that I found l

Categories : Node Js

Mojolicious websocket usage
You will need to connect to the websocket via javascript in the client-side code. The code you have looks like it should work for sending to the client once the connection is established. #!/usr/bin/env perl use Mojolicious::Lite; any '/' => 'index'; websocket '/ws' => sub { my $c = shift; $c->send({ json => { foo => 'bar' } }); }; app->start; __DATA__ @@ index.html.ep <!DOCTYPE html> <html> <head> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script> </head> <body> <p id="result"></p> %= javascript begin var ws = new WebSocket('<%= url_for('ws')->to_abs %>'); ws.onmessage = function (e) { $('#result').text(e.data) }; % end </body> </

Categories : Perl

Websocket on Microsoft Azure?
If you are running in Cloud Services, you will need to be running under osFamily 3. This is how you get your base instance to be running Windows Server 2012. You can find this in your .cscfg file MSDN Reference another MSDN Reference The default project setting was osFamily 1 (Windows Server 2008) which did not support WebSockets. osFamily 2 was Windows Server 2008 R2 which also did not support WebSockets.

Categories : Asp Net

php ratchet websocket SSL connect?
The problem is that React (which Ratchet is built on) does not support direct SSL connections. See this issue. There is a simple workaround. Use stunnel with a config like: [websockets] accept = 8443 connect = 8888 Stunnel will handle SSL traffic on port 8443 and port them to your websocket server.

Categories : PHP

Websocket and reception of a message
If the data has already been sent to the network adapter, there is very little you can do to alter the order of packets. Network adapter will send the packets as and when it gets round to it, in the order you've queued them. If you want to be able to send "higher priority" messages, then don't send off all the data in one go, but hold it in a queue waiting for the device to accept more data, and if a high priority message comes in, send that before you send any of the other packets off. Don't make the packets TOO small, but I guess if you make packets that are a few kilobytes or so at a time, it will work quite swiftly and still allow good control over the flow. Of course, this also will require that the receiver has the understanding of "there may be different 'flows' or 'streams' o

Categories : C++

WebSocket Close Packet
At the simplest level - just close the connection - that'll work fine. The very early hixie-76 has a simple sequence for signalling closure: just send the two bytes 0xFF, 0x00 (the first is the frame type, the second is the length). In all later specifications, frames are a bit more complex; they are broken down as: (1 byte) flags and opcode (variable number of bytes) mask flag and payload length (optional, 4 bytes) mask ({length} bytes) payload For the first part, the opcode we want is 0x08, and this must be combined with the "fin" flag, 0x80 (this just indicates that the frame isn't split over several messages) - so 0x88. For the second part, we can use a zero-length message, but we need to know whether we are client-to-server (always masked, so we need to use 0x80) or server-to-c

Categories : C#

Mojolicious and delayed WebSocket
The problem seems to be that the send message is trying to happen before the GET connection is upgraded to a websocket. I'm still trying to track it down, in the meantime this works. #!/usr/bin/env perl use Mojolicious::Lite; use EV; use AnyEvent; #use POSIX qw(strftime); get '/' => sub { my $self = shift; $self->render('main'); }; websocket '/echo' => sub { my $self = shift; my $w; $self->on(finish => sub { Mojo::IOLoop->remove($w) }); # $self->send(strftime("Server $$: %a %b %e %H:%M:%S %Y", localtime)); $w = Mojo::IOLoop->recurring( 1 => sub{ $self->send('Got it'); }); }; app->start(); __DATA__ @@ main.html.ep <html> <head> <script src="//ajax.googleapis.com/

Categories : HTML

PHP websocket disconnects automatically
my guess is that the socket class is not handling pings/pongs correctly. I've used that socket script before and recall having the same issue. Try https://github.com/lemmingzshadow/php-websocket and see if it's a better starting point. It's more complicated if your just trying to figure out websocket service programming in PHP, but it's a better place to start either way.

Categories : PHP

websocket handshake on node.js
The problem with the code is you are trying to base64 twice. No need to base64 the secKey.Its already in base64. Comment the following lines. var key64=new Buffer(secKey); key64=key64.toString("base64"); Add this code after the above commented lines. var key64 = secKey; After the above modification the errors vanished.

Categories : Node Js

Some users can't connect to websocket
You can set Socket.IO to use only XHR polling in the configuration: io.configure(function () { io.set("transports", ["xhr-polling"]); }); See Configuring Socket.IO in the official documentation.

Categories : Javascript

Websocket connection between two servers
It looks tornado had an ability to also operate as a websocket client. Perhaps you could use this with your front end server acting as a client to the backend server.

Categories : Python

Websocket header missing
I had the same issue while following Ryan Bates's railscast: http://railscasts.com/episodes/260-messaging-with-faye The Faye web socket server requires an adapter to run on Thin web server and send the upgrade header. Add this line to your Faye rackup (.ru) file: Faye::WebSocket.load_adapter('thin') I found this solution here: https://github.com/ryanb/private_pub/issues/39#issuecomment-4225647

Categories : Ruby On Rails

Setting up a websocket on Apache?
I can't answer all questions, but I will do my best. As you already know, WS is only a persistent full-duplex TCP connection with framed messages where the initial handshaking is HTTP-like. You need some server that's listening for incoming WS requests and that binds a handler to them. Now it might be possible with Apache HTTP Server, and I've seen some examples, but there's no official support and it gets complicated. What would Apache do? Where would be your handler? There's a module that forwards incoming WS requests to an external shared library, but this is not necessary with the other great tools to work with WS. WS server trends now include: Autobahn (Python) and Socket.IO (Node.js = JavaScript on the server). The latter also supports other hackish "persistent" connections like l

Categories : Apache

Websocket server connection
I guess you are developing on your local machine which is connected to the internet via a common router with network address translation (NAT). Binding the server to 0.0.0.0 makes sure that the process is listening on all interfaces, that's required and you have it, good. From where did you try to connect to your WebSocket server when using the external IP address? You can't use that one in your local network or even on localhost when you are behind a typical NATed internet connection. When you try to connect to your server from a different machine within the local network, you need to use the local IP address. If you try to connect from "the outside", i.e. from the internet side of your router using the external IP address of your router, then you need to make sure that a port-forward

Categories : PHP



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.