开发者

Flash / AS2 Socket Policy File issue

I've been trying to establish a connection between my flash client and java server for a few days now, but having trouble with the socket policy server.

I've read a lot of info online (including the Adobe guide on how to create one) but still I can't get it to connect, other than in the "Test Movie" option in CS3.

The source for the client and server are pretty long, so I will just try to explain what they do.

OK, so basically I receive the request for <policy-file-request/> in my java server, then I send "<cross-domain-policy><allow-access-from domain='*' to-ports='*' /></cross-domain-policy>" (tried numerous other xml files) followed by a n开发者_Python百科ull character (but keep the connection open, have tried closing it - still didn't work). It seems, however, that the flash client still continues trying to connect for about 10 seconds before giving up.

I also set up a mini-web server inside the java server, which serves a web page on the same port when issued an http-style request, and this seems to work, so it can't be a port-forwarding issue.

I also tried the Adobe example port 843 server, which still didn't work. When accessing the html file in firefox/safari, I can manually approve the connection, and it works.

I read that a crossdomain.xml isn't required for a socket connection, but have experimented none the less.

Where do you think I could be going wrong here?


well i do not use java, but i may suggest two starting points.

First, check if there's a problem with the replacemento of double cotes (") on domain and port configuration. I.e: In VB we may use chr(34) for this indeed. Take a look:

sock.SendData "<cross-domain-policy><allow-access-from domain=" & Chr(34) & "*" & Chr(34) & "to-ports=" & Chr(34) & "50505" & Chr(34) & "/></cross-domain-policy>" & Chr(0)

Second, tracing my app i've found that the flash player 'disconnects' and recconects after receiving the answer for his policy-file. So the sequence is as this:

Server receive request with the msg "policy-file-request/" Server responds the policy file then... it disconnects (!)(?) then it connects again (automaticaly)

The trick is in VB we should close the socket on a sock_Close() event, such as this:

Private Sub sock_Close()
sock.Close                          ' has to be called
sock.Listen                         ' listen again

End Sub

Hope it helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜