Web 服务器与 SQL Server Express 通信时的 TCP 端口
我们有一个 asp.net 3.5 Web 应用程序在托管公司的 Web 服务器上运行,该服务器具有非常严格的防火墙设置。 Web 应用程序与我们位于完全不同网络上的 sql server express 2005 进行通信。
问题是,当 Web 应用程序在端口 1433 上连接到我们的 sql 服务器时,Web 应用程序会向我们的 sql 服务器发送一个随机端口号以进行连接。因此,Web 应用程序无法连接到我们的 sql 服务器,因为这样他们必须打开整个范围防火墙上的端口号,他们不准备这样做。
我的问题如下。 您可以在连接字符串或 web.config 中的某个位置指定客户端发送到 sql server 以连接回的端口吗?
谢谢
We have a asp.net 3.5 web application running on a hosting company's web server that's got a very strict firewall setup. The web application communicates with our sql server express 2005 which is on a completely different network.
The problem is that the web applications sends our sql server a random port number to connect to when it connects to our sql server on port 1433. Hence the web application can not connect to our sql server because then they have to open a whole range off port numbers on the firewall which they are not prepared to do.
My question is the following. Can you specify either in your connection string or somewhere in your web.config the port the client sends to sql server to connect back to on?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果我的理解是正确的,那么您想做的事情违背了 TCP/IP 端口处理的工作方式。
您希望 Web 应用程序在连接到 SQL 服务器时始终使用相同的端口吗? 这意味着在任何给定时间只能打开一个连接,因此在任何给定时间只能有一个用户。 客户端应该从“随机”端口与服务器进行通信。 这是网络的基础知识。 至少我是怎么学会的。
我不确定你是否可以强制它每次都使用相同的端口,即使你可以,我也不建议这样做。
我想说问题出在防火墙上,而不是你的应用程序。 我可以理解,SQL 服务器只想与您的站点所在的 IP 地址进行通信,但它不应该真正关心客户端想要通过哪个端口进行通信(类似于 [website-ip]:* -> [ sql-ip]:1433)。 对我来说,似乎设置防火墙的人都有某种疯狂的防火墙想法,但也许这只是我。
If I'm getting you right, you want to do something that goes against how TCP/IP port handling is supposed to work.
You want the web application to always use the same port when connecting to your SQL server? This would mean you can only have one connection open at any given time, and so only one user at any given time. The client is supposed to communicate with a server from a "random" port. It's the basics of networking. At least how I learned it.
I'm not sure you can even force it to use the same port every time, and even if you can I'd advice against it.
I'd say the problem is the firewall, and not your application. I can understand that the SQL server only wants to speak to the IP address that your site is on, but it shouldn't really care which port the client wants to talk over (something like [website-ip]:* -> [sql-ip]:1433). To me, it seems like who ever set up the firewall has some kind of crazy firewall ideas, but maybe that's just me.
您的 SQL Server Express 是否可能配置为侦听动态端口? 如果“TCP 动态端口”值为 0,我认为即使您配置了特定端口,它也将是动态的。 该值应该被完全清除。
Is it possible that your SQL Server Express is configured to listen on dynamic ports? If the 'TCP Dynamic Ports' value is 0, I think it will be dynamic even if you have a specific port configured. That value should be cleared completely.
如果您使用 TCP/IP,则可以指定端口。
例如:
其中 DBMSSOCN=TCP/IP
You can specify port if you are using TCP/IP.
For ex:
where DBMSSOCN=TCP/IP