<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:47:47 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[CSHARP-4287] Socket.IOControl handles Windows-specific control codes and is not supported on this platform.</title>
                <link>https://jira.mongodb.org/browse/CSHARP-4287</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;We are running a mission-critical application in a Linux container and PlatformNotSupported is being thrown frequently.&#160;&lt;/p&gt;

&lt;p&gt;Looking at C# Driver code, seems we are first trying socket.IOControl and if an exception happens, we try socket.SetSocketOption (&lt;a href=&quot;https://github.com/mongodb/mongo-csharp-driver/blob/master/src/MongoDB.Driver.Core/Core/Connections/TcpStreamFactory.cs#L271&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;reference&lt;/a&gt;), but according to .Net Runtime code, this would always be the case (&lt;a href=&quot;https://github.com/dotnet/runtime/blob/9d6396deb02161f5ee47af72ccac52c2e1bae458/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketPal.Unix.cs#L1352-L1354&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;reference&lt;/a&gt;), as IOControlCode KeepAlive is only supported for windows&#160;(&lt;a href=&quot;https://github.com/dotnet/runtime/blob/9d6396deb02161f5ee47af72ccac52c2e1bae458/src/libraries/System.Net.Sockets/src/System/Net/Sockets/IOControlCode.cs#L59-L60&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;reference&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;For top performance, shouldn&apos;t we check for Platform in order to switch between IOControl or SetSocketOption methods?&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;&lt;span class=&quot;image-wrap&quot; style=&quot;&quot;&gt;&lt;img src=&quot;https://jira.mongodb.org/secure/attachment/393112/393112_image-2022-07-31-21-37-13-912.png&quot; style=&quot;border: 0px solid black&quot; /&gt;&lt;/span&gt;&lt;/p&gt;</description>
                <environment></environment>
        <key id="2103199">CSHARP-4287</key>
            <summary>Socket.IOControl handles Windows-specific control codes and is not supported on this platform.</summary>
                <type id="4" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14710&amp;avatarType=issuetype">Improvement</type>
                                            <priority id="10300" iconUrl="https://jira.mongodb.org/images/icons/priorities/medium.svg">Unknown</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="13201">Fixed</resolution>
                                        <assignee username="james.kovacs@mongodb.com">James Kovacs</assignee>
                                    <reporter username="kaio3henriquemelo@gmail.com">Kaio Henrique</reporter>
                        <labels>
                    </labels>
                <created>Mon, 1 Aug 2022 00:46:27 +0000</created>
                <updated>Sat, 28 Oct 2023 11:47:06 +0000</updated>
                            <resolved>Thu, 11 Aug 2022 17:03:00 +0000</resolved>
                                                    <fixVersion>2.18.0</fixVersion>
                                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="4744722" author="james.kovacs" created="Thu, 11 Aug 2022 17:03:00 +0000"  >&lt;p&gt;Suggested change implemented. We plan to make it available in the 2.18.0 release.&lt;/p&gt;</comment>
                            <comment id="4744710" author="xgen-internal-githook" created="Thu, 11 Aug 2022 17:00:26 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;James Kovacs&apos;, &apos;email&apos;: &apos;jkovacs@post.harvard.edu&apos;, &apos;username&apos;: &apos;JamesKovacs&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/CSHARP-4287&quot; title=&quot;Socket.IOControl handles Windows-specific control codes and is not supported on this platform.&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CSHARP-4287&quot;&gt;&lt;del&gt;CSHARP-4287&lt;/del&gt;&lt;/a&gt;: Only call Socket.IOControl with IOControlCode.KeepAliveValues on Windows. (#863)&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-csharp-driver/commit/fbf97723b5105cd1c4b172acf15f1c2b4b5aefc2&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-csharp-driver/commit/fbf97723b5105cd1c4b172acf15f1c2b4b5aefc2&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="4723198" author="james.kovacs" created="Tue, 2 Aug 2022 19:23:30 +0000"  >&lt;p&gt;Hi, &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=kaio3henriquemelo%40gmail.com&quot; class=&quot;user-hover&quot; rel=&quot;kaio3henriquemelo@gmail.com&quot;&gt;kaio3henriquemelo@gmail.com&lt;/a&gt;,&lt;/p&gt;

&lt;p&gt;Thank you for reporting this issue.&lt;/p&gt;

&lt;p&gt;Reading through &lt;a href=&quot;https://docs.microsoft.com/en-us/dotnet/api/system.net.sockets.socket.iocontrol?view=net-6.0&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;Socket.IOControl&lt;/a&gt; on MSDN, it makes no mention that it should only be used on Windows. Reading through the source code, I can clearly see that it will throw a &lt;tt&gt;PlatformNotSupportedException&lt;/tt&gt; in almost all cases on non-Windows operating systems and that this method should not be used in cross-platform applications. Unfortunately there does not appear to be a way to ascertain whether &lt;tt&gt;Socket.IOControl&lt;/tt&gt; and/or &lt;tt&gt;Socket.SetSocketOption&lt;/tt&gt; is supported on a particular platform with a particular parameters except by attempting to call the API and catching &lt;tt&gt;PlatformNotSupportedException&lt;/tt&gt;. In theory Microsoft could start supporting these API on non-Windows operating systems in a future .NET version.&lt;/p&gt;

&lt;p&gt;All that said, using exception handling for flow control is not desirable. I&apos;ll investigate further whether we can place a platform check around &lt;tt&gt;Socket.IOControl&lt;/tt&gt; (which is a very Windows-specific API) instead of the try/catch block. I&apos;ll update this issue as I learn more.&lt;/p&gt;

&lt;p&gt;In the meantime you can minimize the impact of this behaviour in your application by effective connection pooling as &lt;tt&gt;Socket.IOControl&lt;/tt&gt; and &lt;tt&gt;Socket.SetSocketOption&lt;/tt&gt; are only called once per connection when the underlying socket is opened.&lt;/p&gt;

&lt;p&gt;Sincerely,&lt;br/&gt;
James&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                            <attachment id="393112" name="image-2022-07-31-21-37-13-912.png" size="124303" author="kaio3henriquemelo@gmail.com" created="Mon, 1 Aug 2022 00:36:18 +0000"/>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                        <customfield id="customfield_10011" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Backwards Compatibility</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10011"><![CDATA[Minor Change]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|i0nb9s:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>9223372036854775807</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>