Go Back   CodingForums.com > :: Client side development > Flash & ActionScript

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-12-2009, 11:02 PM   PM User | #1
thesmart1
Regular Coder

 
thesmart1's Avatar
 
Join Date: Dec 2005
Posts: 369
Thanks: 7
Thanked 3 Times in 3 Posts
thesmart1 is an unknown quantity at this point
Allowing XMLSocket Connections

I'm writing a chat client in Flash 8 that uses XMLSockets to connect to a server. Is there a way to set up the client and/or server with policy files, HTML param tags, etc to allow the socket connection without the user having to allow it using the Flash Player Settings Manager?
thesmart1 is offline   Reply With Quote
Old 01-13-2009, 08:32 AM   PM User | #2
gnomeontherun
Senior Coder

 
gnomeontherun's Avatar
 
Join Date: Sep 2007
Location: Houston
Posts: 2,846
Thanks: 10
Thanked 238 Times in 229 Posts
gnomeontherun will become famous soon enoughgnomeontherun will become famous soon enough
I have never used this feature, but I would think having a crossdomain.xml policy file (with all sites permitted) is the first step to try.
__________________
jeremy - gnomeontherun
Educated questions often get educated answers, and simple questions often get simple answers.
gnomeontherun is offline   Reply With Quote
Old 01-13-2009, 06:10 PM   PM User | #3
thesmart1
Regular Coder

 
thesmart1's Avatar
 
Join Date: Dec 2005
Posts: 369
Thanks: 7
Thanked 3 Times in 3 Posts
thesmart1 is an unknown quantity at this point
I've tried that, and I've tried manually loading the policy file with System.security.loadPolicyFile (not sure if this is needed, but I tried anyway).

I can connect to a server and send and receive data from the built-in player in Adobe Flash. When I run the swf movie locally in a standalone player, I get a security warning saying that the player has stopped a potentially unsafe operation, and the connection doesn't even return a failure (no onConnect event). But when I run it in a browser from a webserver, it at least attempts a connection (and the onConnect handler is called with a false success parameter).

EDIT: Demo Flash movie and source code available here if it helps. I have the server running, but this movie (on the same machine and IP as the server) can't connect to it.

Last edited by thesmart1; 01-13-2009 at 07:19 PM..
thesmart1 is offline   Reply With Quote
Old 01-14-2009, 12:42 AM   PM User | #4
thesmart1
Regular Coder

 
thesmart1's Avatar
 
Join Date: Dec 2005
Posts: 369
Thanks: 7
Thanked 3 Times in 3 Posts
thesmart1 is an unknown quantity at this point
Oh wow, after some packet-watching with Wireshark, communication monitoring with telnet and server-side packet logging, and lots of research, I noticed Flash Player was indeed connecting to first port 843, then port 80 (when i used loadPolicyFile with a port number), then the port of my server program. I still can't figure out why the HTTP request to port 80 failed though; I found a single request in the Apache access logs: "GET /crossdomain.xml HTTP/1.1" 200 543 "http://pehjota.com/crossdomain.xml" "Shockwave Flash". On my server I noticed Flash was sending <policy-file-request/>, so I passed the contents of my crossdomain.xml file through the socket and Flash Player accepted it. So after several hours of investigation I finally got my Flash Player client to connect to and communicate with my server! Though it's still a bit weird that Flash Player only sent one HTTP request and seemed it didn't like the response, and so now I have to add a response to my server to handle policy file requests...

More information on policy files and how they relate to socket connections - specifically of interest on that page is "Socket policy request process"
thesmart1 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:55 PM.


Advertisement
Log in to turn off these ads.