项目中用到WebOrb的Real-time messaging,考虑到rtmp协议需要配置服务器防火墙打开2037端口,最终选择rtmpt协议。配置中遇到一些麻烦,主要是iis7还是不熟悉,经过一番周折还是搞定了。以下是WebOrb官方的配置指导:
http://www.themidnightcoders.com/fileadmin/docs/dotnet/guide/index.htm
WebORB provides support for RTMPT thus enabling communication between real-time messaging clients and server applications, streams and remote shared objects over port 80. There are special configuration requirements for RTMPT:
- WebORB must be deployed in the root of a website.
- Special HTTP handler mappings must be added to web.config
- The website must be configured to route POST requests via ASP.NET
Follow the steps described below to configure IIS and WebORB to process RTMPT requests:
- Configure website root to run as an application.
Open IIS Manager and select the root node for the website where RTMPT must be enabled. Open the Properties window and select the 'Home Directory' tab:
In the Application Settings section, make sure there is an application associated with the website. If not, click the Create button to the right from the Application name field.
- Configure application to route requests through ASP.NET.
Click the Configuration button in the Application Settings section of the Home Directory tab.
Click "Insert..." to add a wildcard application map and enter the full path to aspnet_isapi.dll for your .NET installation.
(path in our testing environment is c:\windows\microsoft.net\framework\v2.0.50727\aspnet_isapi.dll).
Make sure to uncheck the "Verify that file exists" checkbox.
Click OK to accept the values. - Deploy WebORB in the website root.
Create "bin" folder and copy the following assemblies from the default WebORB installation path (wwwroot/weborb30/bin):- weborb.dll
- cpuinfo.dll
- Npgsql.dll
- NHibernate.dll
- MySql.Data.dll
- Mono.Security.dll
- any assemblies with user application code
Copy weborb.config into the website root folder.
- Deploy messaging applications.
Create /Applications folder in the website root folder. Create subfolders corresponding to the messaging applications. A subfolder may contain application configuration file (app.config) with a reference to the application handler class
- Register WebORB RTMPT handler.
If there is no web.config in the website root folder, copy it from the default WebORB installation directory (wwwroot/weborb30).
Add the following configuration to the <httpHandlers> section:
<add verb="*" path="/open/*" type="Weborb.Messaging.Net.RTMPT.RTMPTHttpHandler"/>
<add verb="*" path="/send/*" type="Weborb.Messaging.Net.RTMPT.RTMPTHttpHandler"/>
<add verb="*" path="/idle/*" type="Weborb.Messaging.Net.RTMPT.RTMPTHttpHandler"/>
<add verb="*" path="/close/*" type="Weborb.Messaging.Net.RTMPT.RTMPTHttpHandler"/>
<add verb="*" path="/open/*/*" type="Weborb.Messaging.Net.RTMPT.RTMPTHttpHandler"/>
<add verb="*" path="/send/*/*" type="Weborb.Messaging.Net.RTMPT.RTMPTHttpHandler"/>
<add verb="*" path="/idle/*/*" type="Weborb.Messaging.Net.RTMPT.RTMPTHttpHandler"/>
<add verb="*" path="/close/*/*" type="Weborb.Messaging.Net.RTMPT.RTMPTHttpHandler"/>
IIS7中的设置
选择"Handler Mappings" -> "Add Wildcard Script Map..."
Choose aspnet_isapi.dll as an executable and give this script mapping some meaningful name, such as ASP.NET-ISAPI-2.0-Wildcard. After that click OK and then click Yes in the "Add Wildcard Script Map" dialog.
Next, switch to the ordered list view for the handler mappings by clicking on "View Ordered List..." action and move the newly created mapping to the bottom of the list just before the StaticFile handler mapping:
最关键的一点,对应官方给的II6中配置第五步,添加相应的托管HttpHandler(IIS7的Handler Mappings右侧 Add Managed Handler...)
根据官方第5步Register WebORB RTMPT handler.填写相应的请求路径
全部加好后:
比较一下IIS6和IIS7的Web.config不同之处
IIS6:
<system.web>
<httpHandlers>
<add verb="*" path="/open/*" type="Weborb.Messaging.Net.RTMPT.RTMPTHttpHandler" />
<add verb="*" path="/send/*" type="Weborb.Messaging.Net.RTMPT.RTMPTHttpHandler" />
<add verb="*" path="/idle/*" type="Weborb.Messaging.Net.RTMPT.RTMPTHttpHandler" />
<add verb="*" path="/close/*" type="Weborb.Messaging.Net.RTMPT.RTMPTHttpHandler" />
<add verb="*" path="/open/*/*" type="Weborb.Messaging.Net.RTMPT.RTMPTHttpHandler" />
<add verb="*" path="/send/*/*" type="Weborb.Messaging.Net.RTMPT.RTMPTHttpHandler" />
<add verb="*" path="/idle/*/*" type="Weborb.Messaging.Net.RTMPT.RTMPTHttpHandler" />
<add verb="*" path="/close/*/*" type="Weborb.Messaging.Net.RTMPT.RTMPTHttpHandler" />
<add verb="*" path="weborb.aspx" type="Weborb.ORBHttpHandler" />
<add verb="*" path="codegen.aspx" type="Weborb.Management.CodeGen.CodegeneratorHttpHandler" />
</httpHandlers>
...
</system.web>
IIS7:(注意IIS7中会使用最下面的 <system.webServer>节点)
<system.webServer>
<handlers>
<add name="rtmptHttpHandler1" verb="*" path="/open/*" type="Weborb.Messaging.Net.RTMPT.RTMPTHttpHandler" resourceType="Unspecified" preCondition="integratedMode"/>
<add name="rtmptHttpHandler2" verb="*" path="/send/*" type="Weborb.Messaging.Net.RTMPT.RTMPTHttpHandler" resourceType="Unspecified" preCondition="integratedMode"/>
<add name="rtmptHttpHandler3" verb="*" path="/idle/*" type="Weborb.Messaging.Net.RTMPT.RTMPTHttpHandler" resourceType="Unspecified" preCondition="integratedMode"/>
<add name="rtmptHttpHandler4" verb="*" path="/close/*" type="Weborb.Messaging.Net.RTMPT.RTMPTHttpHandler" resourceType="Unspecified" preCondition="integratedMode"/>
<add name="rtmptHttpHandler5" verb="*" path="/open/*/*" type="Weborb.Messaging.Net.RTMPT.RTMPTHttpHandler" resourceType="Unspecified" preCondition="integratedMode"/>
<add name="rtmptHttpHandler6" verb="*" path="/send/*/*" type="Weborb.Messaging.Net.RTMPT.RTMPTHttpHandler" resourceType="Unspecified" preCondition="integratedMode"/>
<add name="rtmptHttpHandler7" verb="*" path="/idle/*/*" type="Weborb.Messaging.Net.RTMPT.RTMPTHttpHandler" resourceType="Unspecified" preCondition="integratedMode"/>
<add name="rtmptHttpHandler8" verb="*" path="/close/*/*" type="Weborb.Messaging.Net.RTMPT.RTMPTHttpHandler" resourceType="Unspecified" preCondition="integratedMode"/>
<add name="codegen.aspx_*" path="codegen.aspx" verb="*" type="Weborb.Management.CodeGen.CodegeneratorHttpHandler" preCondition="integratedMode,runtimeVersionv2.0" />
<add name="weborb.aspx_*" path="weborb.aspx" verb="*" type="Weborb.ORBHttpHandler" preCondition="integratedMode,runtimeVersionv2.0" />
</handlers>
...
</system.webServer>
另外,值得一提的是flex代码中的NetConnection实例的uri要做相应修改
例如
原:"rtmp://192.168.1.123:2037/Chat/"
修改后::"rtmpt://192.168.1.123/Chat/"