Using a selector to detect closed socket channel.

Basically our app uses one thread to perform a select on multiple socket channels. When a socket is closed (either remotely or locally) the server app needs to unregister the client (so we need to detect closed channels). We've been using blocking IO previously (no dramas), but now we're dealing with many connections/clients we need to rework it as we're getting excessive amounts of threads. Anyway, that's just background.
Here's the problem we're getting, I have boiled it down to the following.
SocketChannel channel = SocketChannel.open();
channel.connect(socketAddress); // for the test this is localhost.
// this make sure socket is open, remote end just echos, waits 3 seconds and closes the socket.
channel.write(ByteBuffer.wrap("testLocalSocketClose\n".getBytes()));
channel.configureBlocking(false);
Selector selector = Selector.open();
LOG.fine("registering channel");
channel.register(selector, SelectionKey.OP_READ, channel);
LOG.fine("closing channel");
channel.close();
LOG.fine("waiting...");
int i = selector.select();
// this never happens (or it does very rarely)
LOG.fine("selector woke with " + i + " selected");I would have expected the selector to return the selection key of the dead channel. Given that it doesn't and this scenario is possible (channel closing just after a read operation but before another select is called - in separate threads obviously). How can we reliably detect/be informed that the channel has been closed?
(I saw somewhere someone mention adding the OP_WRITE to the key, I have tried this as well and it makes no difference).
Many Thanks.
Bob.

May I suggest you look at your application and reassess; either it's wrong or it's your understanding of what our issue is.
Please try the simple test below.
WSADATA ws;
WSAStartup(0x0101, &ws);
SOCKET sock = socket(PF_INET, SOCK_STREAM, 0);
struct sockaddr_in server;
server.sin_family = AF_INET;
server.sin_addr.s_addr = htonl(INADDR_ANY);
server.sin_port = htons(9000);
cout << "binding" << endl;
bind(sock, (struct sockaddr *)&server, sizeof(server));
cout << "listening" << endl;
listen(sock, SOMAXCONN);
struct sockaddr_in client;
int client_size = sizeof(client);
memset(&client, 0, client_size);
cout << "accepting" << endl;
SOCKET clientSock = accept(sock, (struct sockaddr*)&client, &client_size);
// shutdown socket.
cout << "shutting down client socket" << endl;
shutdown(clientSock, SD_BOTH);
// setup select
FD_SET fd;
TIMEVAL tv;
FD_ZERO(&fd);
tv.tv_sec  = static_cast<int>(6000);
tv.tv_usec = 0;
FD_SET(clientSock, &fd);
cout << "selecting" << endl;
int rc = select(0, &fd, NULL, NULL, &tv);     
cout << rc << ", " << FD_ISSET(clientSock, &fd) << endl;
char msg[500];
if (FD_ISSET(clientSock, &fd)) {
     cout << recv(clientSock, msg, 500, 0) << endl;
     cout << WSAGetLastError() << endl;
cout << "closing" << endl;
closesocket(clientSock);Telnet to port 9000, you get the following output immediately:
binding
listening
accepting
shutting down client socket
selecting
1, 1
-1
10058
closing
The solution I posted previously re calling shutdownInput/Output in Java isn't correct however, I left OP_WRITE on by mistake, which always returns ready, my fault.  Apologies.
Whatever the behaviour, it will be the same for Selector.select() as it is for select().
Clearly not.
Edited by: Bawb on 29-Jul-2011 07:01, I had left OP_WRITE on which was returning ready each time, when I realised and took it out I removed the shutdown code which made me think I hadn't sorted this. Apologies again.
Still reckon an RFE for OP_SHUTDOWN should be added to Java.
Thanks.

Similar Messages

  • Issue: Detected use of SPRequest for previously closed SPWeb object

    I have a solution to create web site by a custom web template. I used ULS Viewer to monitor the sharepoint error log during the process. I see some unexpected error(Detected use of SPRequest for previously closed SPWeb object.  Please close SPWeb
    objects when you are done with all objects obtained from them, but not before.)
    I believe that It will bring up a memory leak issue in anytime future. so I spend some time to find the root cause. It has no unexpected issue by creating web site with out of the box template(BLOG,WIKI, etc). I will get only get it with custom
    template. Does anyone know the reason and soltuon for this issue? Thanks.

            protected void Button2_Click(object sender, EventArgs e)
                string Client = "Client";
                string creatorId = "UserId";
                string creatorname = "Robin Hung";
                string rreatorEmail = "[email protected]";
                SPSecurity.RunWithElevatedPrivileges(delegate()
    using (
    SPSite newSite =
    new SPSite("http://localhost/sites/" + Client))
    SPWebTemplateCollection WTC =
    newSite.GetWebTemplates(1033);
    SPWebTemplate webTemplate =
    newSite.GetWebTemplates(1033)["SubSite"];
    newSite.AllowUnsafeUpdates = true;
    SPDiagnosticsService.Local.WriteTrace(0,
    new SPDiagnosticsCategory
    ("Log",
    TraceSeverity.
    Verbose,
    EventSeverity.
    Verbose),
    TraceSeverity.Verbose,
    "Test 2", "Called");
    using (SPWeb spWeb = newSite.OpenWeb())
    SPDiagnosticsService.Local.WriteTrace(0,
    new SPDiagnosticsCategory
    ("Log",
    TraceSeverity
    .Verbose,
    EventSeverity
    .Verbose),
    TraceSeverity.
    Verbose,
    "Test 21",
    "Called");
    spWeb.AllowUnsafeUpdates = true;
    spWeb.Webs.Add("Robin4", "Robin2", "test", 1033,
    webTemplate, false, false);
    SPDiagnosticsService.Local.WriteTrace(0,
    new SPDiagnosticsCategory
    ("Log",
    TraceSeverity
    .Verbose,
    EventSeverity
    .Verbose),
    TraceSeverity.
    Verbose,
    "Test 211",
    "Called");
    spWeb.Webs.Add("Robin5", "Robin2", "test", 1033,
    WTC["SubSite"], false, false);
    SPDiagnosticsService.Local.WriteTrace(0,
    new SPDiagnosticsCategory
    ("Log",
    TraceSeverity
    .Verbose,
    EventSeverity
    .Verbose),
    TraceSeverity.
    Verbose,
    "Test 212",
    "Called");
    spWeb.Webs.Add("Robin6", "Robin2", "test", 1033,
    WTC[30], false, false);
    SPDiagnosticsService.Local.WriteTrace(0,
    new SPDiagnosticsCategory
    ("Log",
    TraceSeverity
    .Verbose,
    EventSeverity
    .Verbose),
    TraceSeverity.
    Verbose,
    "Test 213",
    "Called");
    spWeb.AllowUnsafeUpdates = false;
    SPDiagnosticsService.Local.WriteTrace(0,
    new SPDiagnosticsCategory
    ("Log",
    TraceSeverity
    .Verbose,
    EventSeverity
    .Verbose),
    TraceSeverity.
    Verbose,
    "Test 22",
    "Called");
    newSite.AllowUnsafeUpdates = false;
    //currentSite.AllowUnsafeUpdates = false;
    SPDiagnosticsService.Local.WriteTrace(0,
    new SPDiagnosticsCategory
    ("Log",
    TraceSeverity.
    Verbose,
    EventSeverity.
    Verbose),
    TraceSeverity.Verbose,
    "Test 4", "Called");

  • Detected use of SPRequest for previously closed SPWeb object. Please close SPWeb objects when you are done with all objects obtained from them

    HI
    i am keep seeing this message in ulsviewer of splogs in a webfront end server
    Detected use of SPRequest for previously closed SPWeb object.  Please close SPWeb objects when you are done with all objects obtained from them, but not before.  Stack trace:  
    at Microsoft.SharePoint.SPWeb.get_Exists()   
    at Microsoft.SharePoint.WebControls.CssLink.OnLoad(EventArgs e)   
    at System.Web.UI.Control.LoadRecursive()   
    at System.Web.UI.Control.LoadRecursive()   
    at System.Web.UI.Control.LoadRecursive()   
    at System.Web.UI.Control.LoadRecursive()   
    at System.Web.UI.Control.LoadRecursive()   
    at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)   
    at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)   
    at System.Web.UI.Page.ProcessRequest()   
    at System.Web.UI.Page.ProcessRequest(HttpContext context)   
    at ASP._layouts_icc_icc_scan_view_aspx.ProcessRequest(HttpContext context)   
    at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()   
    at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)   
    at System.Web.HttpApplication.PipelineStepManager.ResumeSteps(Exception error)   
    at System.Web.HttpApplication.BeginProcessRequestNotification(HttpContext context, AsyncCallback cb)   
    at System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context)   
    at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr managedHttpContext, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)   
    at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr managedHttpContext, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)   
    at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr managedHttpContext, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)   
    at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr managedHttpContext, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)
    adil

    Hi,
    Your SPweb object is not disposed properly.
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/3a25eb86-8415-4053-b319-9dd84a1fd71f/detected-use-of-sprequest-for-previously-closed-spweb-object-please-close-spweb-objects-when-you?forum=sharepointdevelopmentprevious
    http://sharepoint.stackexchange.com/questions/50793/detected-use-of-sprequest-for-previously-closed-spweb-object-after-spquery
    Please remember to click 'Mark as Answer' on the answer if it helps you

  • Detected use of SPRequest for previously closed SPWeb object. Please close SPWeb objects when you are done with all objects obtained from them, but not before.

    I have develop a custom solution for SharePoint Foundation 2010 that provide PDF documents filled with lists data and attachemnts.
    If the Customer run the solution to get the PDF we found in the ULS log following entry:
    03/07/2014 12:07:20.69  w3wp.exe (0x0B10) 0x18EC 
    SharePoint Foundation General                        90hv Unexpected 
    Detected use of SPRequest for previously closed SPWeb object.  Please close SPWeb objects when you are done with all objects obtained from them, but not before.  Stack trace:    at Microsoft.SharePoint.Utilities.SPUtility.GetLocalizedString(String
    source, String defaultResourceFile, UInt32 language)     at Microsoft.SharePoint.SPFieldCollection.get_DisplayNameDict()     at Microsoft.SharePoint.SPFieldCollection.GetFieldByDisplayName(String strDisplayName, Boolean
    bThrowException)     at Microsoft.SharePoint.SPFieldCollection.GetField(String strName, Boolean bThrowException)     at Microsoft.SharePoint.SPListItem.GetValue(String strName, Boolean bThrowException)    
    at Microsoft.SharePoint.SPListItem.get_Item(String fieldName)    
    at ECM_PDF_Excel.ListClicked.GetECOs(Dictionary`2 searchedEC... e918ecd4-7ed6-44bb-9e4f-d764586a2f79 ...RECONumber)    
    at ECM_PDF_Excel.PDF.Create()     at ECM_PDF_Excel.Layouts.ECM_PDF_Excel.ECMPDFExcel.ProcessRequest(HttpContext context)     at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()    
    at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)     at System.Web.HttpApplication.PipelineStepManager.ResumeSteps(Exception error)     at System.Web.HttpApplication.BeginProcessRequestNotification(HttpContext
    context, AsyncCallback cb)     at System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context)     at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr
    managedHttpContext, IntPtr nativeRequestContext, IntPtr moduleData, Int32 f... e918ecd4-7ed6-44bb-9e4f-d764586a2f79
    03/07/2014 12:07:20.69* w3wp.exe (0x0B10)                        0x18EC SharePoint Foundation        
     General                        90hv Unexpected ...lags)     at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr
    managedHttpContext, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)     at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr managedHttpContext, IntPtr nativeRequestContext, IntPtr moduleData, Int32
    flags)     at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr managedHttpContext, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)   e918ecd4-7ed6-44bb-9e4f-d764586a2f79
    We check the method
            /// <summary>
            /// Returns the ECOs in a Dictionary: ECO Number, Suffix
            /// </summary>
            /// <param name="searchedECRECONumber">Dictionary, with the search ECR/ECO Number</param>
            /// <returns>Dictionary ECO Number, Suffix</returns>
            public static Dictionary<string, string> GetECOs(Dictionary<String, String> searchedECRECONumber)
                SPSite siteContx = SPContext.Current.Site;
                SPWeb webContx = siteContx.RootWeb;
                Dictionary<string, string> listECOs = new Dictionary<string, string>();
                string ecoNumber = string.Empty;
                string ecoSuffix = string.Empty;
                if (searchedECRECONumber.ContainsKey(ConstantData.listClickedECONumberDictionary))
                    ecoNumber = searchedECRECONumber[ConstantData.listClickedECONumberDictionary];
                else
                    return listECOs;
                // Ich suche die ECO Nummber bei gegebener ECR Nummer
                // Ich brauche den Listen Namen der in den Spalten Realtion ECR Number & Realtion ECO Number einen Wert hat
                SPList dataList = webContx.Lists.TryGetList(ConstantData.listName_ECMExcelTemplateDataLists);
                if (dataList != null)
                    SPListItemCollection dataListItems = webContx.Lists.TryGetList(ConstantData.listName_ECMExcelTemplateDataLists).Items;
                    foreach (SPItem dataListItem in dataListItems)
                        Object relationECRColumnName = (String)dataListItem[ConstantData.listFieldName_ECMExcelTemplateDataLists_RelationECRNumber];
                        Object relationECOColumnName = (String)dataListItem[ConstantData.listFieldName_ECMExcelTemplateDataLists_RelationECONumber];
                        if (relationECRColumnName != null && relationECOColumnName != null)
                            // Ich habe den Listennamen gefunden in dem Spalten Realtion ECR Number & Realtion ECO Number einen Wert haben
                            string searchedListName = (String)dataListItem[ConstantData.listFieldName_ECMExcelTemplateDataLists_Title];
                            string searchedECOSuffixColumnName = (String)dataListItem[ConstantData.listFieldName_ECMExcelTemplateDataLists_RelationECONumber];
                            // Get the List from variable listName
                            listECOs = GetECOsDictionary(searchedListName, searchedECOSuffixColumnName, ecoNumber, relationECOColumnName);
                return listECOs;
    - What take we wrong?
    - How can we avoid this message?
    Regards
    Jonnyenglisch
    Ralf Happe - Christobal Colón N° 1 ES 07670 Portocolom Tel.: +34 6961 0375 7 @: [email protected] Skype: ralfhappe msm: [email protected] www.ralfhappe.com ralfhappe | soluciónes

    Here the code of GetECOsDictionary:
             /// <summary>
            /// Fill the dicionary with related ECO Numbers/Suffix
            /// </summary>
            /// <param name="searchedListName">String: the name of the list</param>
            /// <param name="ecoNumber">String: the ECO Number</param>
            /// <param name="relationECOColumnName"></param>
            /// <returns>Dictionary</returns>
            private static Dictionary<string, string> GetECOsDictionary(string searchedListName, string ecoNumber, Object relationECOColumnName)
                SPSite siteContx = SPContext.Current.Site;
                SPWeb webContx = siteContx.RootWeb;
                Dictionary<string, string> listECOs = new Dictionary<string, string>();
                SPQuery oQuery = new SPQuery();
                oQuery.Query = "<OrderBy>" +
                                    "<FieldRef Name='" + "Title" + "' Ascending='TRUE'></FieldRef>"
    +
                                "</OrderBy>" +
                                "<Where><BeginsWith>" +
                                    "<FieldRef Name='" + "Title" + "'/>" +
                                    "<Value Type='Text'>" + ecoNumber + "</Value>" +
                                "</BeginsWith></Where>";
                SPListItemCollection searchedListItems = webContx.Lists.TryGetList(searchedListName).GetItems(oQuery);
                foreach (SPItem searchedListItem in searchedListItems)
                    // Wenn die geclickte ECO Nummer gleich der Listen ECO Nummer ist dann setze die gefundene ECO Nummer
                    string foundECONumber = (String)searchedListItem[relationECOColumnName.ToString()];
                    string[] splitECONumber = foundECONumber.Split(ConstantData.splitBy_Slash);
                    if (ecoNumber == splitECONumber[0])
                        ecoNumber = splitECONumber[0];
                        if (splitECONumber.Count() == 1)
                            listECOs.Add(foundECONumber, "0");
                        if (splitECONumber.Count() > 1)
                            listECOs.Add(foundECONumber, splitECONumber[1]);
                return listECOs;
    Ralf Happe - Christobal Colón N° 1 ES 07670 Portocolom Tel.: +34 6961 0375 7 @: [email protected] Skype: ralfhappe msm: [email protected] www.ralfhappe.com ralfhappe | soluciónes

  • Urgent: Child process closed admin channel on Solaris 9 and 6.1 SP5

    Hi
    I'm facing this issue on Solaris 9 and Sun AppServer 6.1 SP5, the appserver crashes for some reason and restarts itself. There doesnt seem to be any specific instance which leads to this error. I notice that if I leave my application running for a while I end up seeing this error and I need to kill the instance that was running and restart the server instance.
    This is what i see in the log files before the server restarts itself.
    " failure (12181): CORE3107: Child process closed admin channel"
    It seems like i'm not the only one seeing this issue:
    http://swforums.sun.com/jive/thread.jspa?threadID=55040&messageID=210473
    http://forum.sun.com/jive/thread.jspa?threadID=95718&messageID=328813
    Anybody knows what could be going on?
    Thanks

    After the corefile is written, use pstack on it. In the pstack file you a stacktrace of the crashing function. Alas, this information is only useful when you have the sources.
    Also, usually there are other, more specific lines in the errors logfile e.g.:
    [27/Jan/2006:07:38:55] catastrophe (15456): CORE3260: Server crash detected (signal SIGSEGV)
    [27/Jan/2006:07:38:55] info (15456): CORE3262: Crash occurred in function INTprepare_nsapi_thread from module /opt/SUNWwbsvr/bin/https/lib/libns-httpd40.so
    [27/Jan/2006:07:38:55] failure (15455): CORE3107: Child process closed admin channel
    If you post them, maybe somebody can give you a hint...

  • Sun Ray Connector proxy : Child closed socket prematurely, session shutdown

    Dear All,
    I'm using SRS 5 & SRWC 2.2 :
    $ pkginfo -l SUNWuttsc
       PKGINST:  SUNWuttsc
          NAME:  Sun Ray Connector for Microsoft Windows Operating Systems (opt)
      CATEGORY:  system,sunray
          ARCH:  i386
       VERSION:  2.2_32
       BASEDIR:  /opt
        VENDOR:  Sun Microsystems, Inc.
          DESC:  Commands, configuration, resources and Man Pages
        PSTAMP:  SunOS_5.10_20091021175007
      INSTDATE:  févr 05 2010 10:34
       HOTLINE:  Please contact your local service provider
        STATUS:  Installation complète.
         FILES:       26 chemins d'accès installés
                       9 répertoires
                      10 exécutables
                       1 exécutables setuid/setgid
                    9037 blocs utilisés (env.)
    The SRWC crash and restart immediately...
    As you can see I've some log like this :
    Feb  7 03:03:15 SRS Sun Ray Connector proxy:[18056]: [ID 855542 user.error] Child closed socket prematurely, session shutdown
    Feb  7 03:03:15 SRS Sun Ray Connector proxy:[18089]: [ID 855542 user.error] Child closed socket prematurely, session shutdown
    Feb  7 03:03:23 SRS Sun Ray Connector proxy:[18254]: [ID 855542 user.error] Child closed socket prematurely, session shutdown
    Feb  7 03:03:23 SRS Sun Ray Connector proxy:[18214]: [ID 855542 user.error] Child closed socket prematurely, session shutdown
    Feb  7 03:03:23 SRS Sun Ray Connector proxy:[18219]: [ID 855542 user.error] Child closed socket prematurely, session shutdown
    Feb  7 03:03:23 SRS Sun Ray Connector proxy:[18221]: [ID 855542 user.error] Child closed socket prematurely, session shutdown
    Feb  7 03:03:23 SRS Sun Ray Connector proxy:[18220]: [ID 855542 user.error] Child closed socket prematurely, session shutdown
    ...I'm using a separate DHCP on LAN. DTU & TSE (W2K8) are working 95% of time and sometime and randomly, one DTU has a full black screen. The only way to get the login screen of win 2K8 is to reset his own session.
    Help will be really appreciated.
    Florent.

    I have the same issue . . .
    1. Sun Ray 5 (Sun Ray 4.2)
    2. SRWC 2.2
    3. Solaris 10 u9 X86 on two x2200
    4. Terminal Server on Win2K3 R2 Standard x64 Edition SP2
    I have a handful of users and they all logon the same way, which is to enter username & password then I have the following lines at the end of the users' individual .dtprofile file . . .
    <begin snip>
    DTSOURCEPROFILE=true
    /opt/SUNWuttsc/bin/uttsc -b -m -O -u uname 192.168.100.29
    exit
    <end snip>
    Of course 'uname' is actually the user name followed by the Terminal Server IP address and as you can see I am using the '-O' option, but every morning all the users on a server have their Sun Ray sessions reset and I find this in the messages file . . .
    Mar 16 09:38:31 sunraya Sun Ray Connector proxy:[12941]: [ID 855542 user.error] Child closed socket prematurely, session shutdown
    . . . . Using cron, I reset the Sun Ray service twice a day on both servers at 7AM and 7PM . . .
    # cat /sunray-restart.script
    # This is to restart SunRay 5 service due to
    # what I think may be a memory leak that disconnects
    # the SunRay Windows Connector every day
    /opt/SUNWut/sbin/utrestart -c
    echo "#" >> /var/adm/messages
    date >> /var/adm/messages
    echo "#" >> /var/adm/messages
    echo " RESTARTING SUNRAY SERVICE " >> /var/adm/messages
    echo "#" >> /var/adm/messages
    echo "#" >> /var/adm/messages
    . . . But this does not appear to having an affect.
    I will be looking around the forums for any other bits of information about this. The "Known Issues" can probably be found in the Release Notes.

  • Closing Sockets

    Hi all,
    Im having a big problem with the closing of sockets.
    I have a simple program which handles the sending / receiving and monitoring of HTTP traffic.
    My program has a 'sender' part which opens a socket, writes a request (using the socket output stream), reads the response (using the socket input stream, until read() == -1 ) and then closes the streams and socket.
    The 'receiver' part simply receives socket connections, reads the content (until read() == -1), writes a response, and then closes the streams and socket.
    The monitor part is a simple 'tunnel'. For each received socket connection, a connection is made to a server.
    Two threads then operate like this:
    T1) While read from client != -1, write to server
    T2) While read from server != -1, write to client
    Seems simple enough, and sort of works.
    The problem I have is cleanly closing all sockets without screwing up either the tunnel or a client.
    I try not to close the streams / sockets at the 'logical' times, but for some reason any combination I try results in Socket Closed exceptions during a read in either the tunnel or the client.
    There is a fair amount of code - so I dont expect anyone to wade thru it to find the problem, but Im just wondering if anyone has:
    1) Had similar problems and found a solution
    2) Can point me in the direction for more details on the mechanics and implications of closing socket streams
    The java docs seem very sketchy on this subject!!
    Thanks for your help!

    Thanks for the response (2 dukes for the fast reply - plenty more available on this one though!)....
    Does this mean that there is no 'clean' way to accomplish the transfer task?
    I think both examples will work, but I have a couple of issues:
    This exception is quite normal and indicates that another thread abruptly forced your socket closed or you tried to read or write after closing it yourself. You must catch it.The problem I have with this is that under these circumstances, it is a 'SocketException' which is thrown. The API says that this is thrown if 'there is an error in the underlying protocol, such as a TCP error'. So to be sure I was dealing with the right problem, I'd have to start parsing the exception text looking for "Socket Closed".
    Im keener on option 2:
    providing signalling between your threads Sounds like this is what I need.... Again there is a catch though.
    See, the thread handling the client will be in a blocking read (it will have read everything from the client, and written it to the server. However, as the client socket isn't closed yet, it doesn't know its time to stop). So, Im back to using exceptions again (Im assuming I'd have to do an interrupt?).
    I thought I could get round this on the client side by closing the output stream after writing everything (would signify to the reader thread that all is done).
    This, however, just results in the socket getting closed (my ignorance of the underlying mechanics of sockets showing through here...).
    Further, I want my 'monitor' to work with all request / response based systems - so I cant write a termination sequence on the client side to indicate end of input.
    So - Im really stuck with using exceptions as flags then??

  • Closing socket as no data read

    Hi,
    I am using weblogic 10.3 application server. I am frequently facing the below warning in log file
    <BEA-000449> <Closing socket as no data read from it during the configured idle timeout of *0 secs*>
    As a response, "Page cannot be displayed" error is seen in browser for that request. I checked the config.xml, nowhere it is configured as 0 seconds.
    Please help me with your suggestions.
    Regards
    Purushoth
    Edited by: user13299431 on Nov 29, 2010 2:01 AM

    [Refer to this link|http://forums.oracle.com/forums/thread.jspa?messageID=9114422]

  • Programmatically detect a PI channel stopped in RWB

    Hello,
    Does anybody know a way to programmatically detect a PI channel stopped in RWB?
    Thanks,
    Shawn

    Hi,
    To control communication channels externally, you use an HTTP GET or POST request to the following URL:
    http(s)://host:port/AdapterFramework/ChannelAdminServlet?party=party&service=service&channel=channel&action=action
    See this wiki,
    http://wiki.sdn.sap.com/wiki/display/XI/ExternallyControllingtheCommunicationChannel
    http://help.sap.com/saphelp_nwpi711/helpdata/en/45/0c86aab4d14dece10000000a11466f/content.htm
    You can easily control comm channel through external control.
    Please refer the HELP.SAP material on this.
    In RWB you need to enable external control on communication channel.
    http://help.sap.com/saphelp_nwpi71/helpdata/en/45/0c86aab4d14dece10000000a11466f/content.htm
    To control communication channels externally, you use an HTTP GET or POST request to the following URL:
    http(s)://host:port/AdapterFramework/ChannelAdminServlet?party=party&service=service&channel=channel&action=action
    The XML structure of the HTTP response is documented in a document type definition (DTD) and an XML schema definition (XSD). You can call this information using HTTP at the following addresses:
    ● http(s)://host:port/AdapterFramework/channelAdmin/ChannelAdmin.dtd
    ● http(s)://host:port/AdapterFramework/channelAdmin/ChannelAdmin.xsd
    You can try this through internet explorer also
    http(s)://host:port/AdapterFramework/ChannelAdminServlet?party=party&service=service&channel=channel&action=action

  • Closing Socket within 0 Seconds

    Hi,
    I am using weblogic 10.3 application server. I am frequently facing the below warning in log file
    <BEA-000449> <Closing socket as no data read from it during the configured idle timeout of *0 secs*>
    As a response, "Page cannot be displayed" error is seen in browser for that request. I checked the config.xml, nowhere it is configured as 0 seconds.
    Please help me with your suggestions.
    Regards
    Edited by: user13299431 on Nov 29, 2010 4:36 AM

    Hi
    This is message you can filter it thru LogFilter
    You can set the Logfileter on your Admin console -> Click on Domain->Configuration->Log Filters->create new Log filter.
    I added this line in expression "(MESSAGE !='Closing socket as no data read from it during the configured idle timeout of 0 secs')"
    Go to your server-(for each server you have to set it individually)->Logging->Advanced->Select this log filter for Standard Out or log file
    Ref:
    BEA-000449  Closing socket as no data read from it
    http://download.oracle.com/docs/cd/E15051_01/wls/docs103/ConsoleHelp/taskhelp/domain_log_filters/CreateLogFilters.html
    Hope this will helps you.

  • Windows7 64-bit causes BEA-000449 Closing socket as no data read

    Hi,
    I have a new Windows7 64-bit laptop and copied my ADF and other FMW apps to the new laptop from my windows XP. I am using Jdev 11.1.1.5 on the prior XP and the new Windows7.
    The applications ran fine in XP and I am able to run the the JSPX pages in the windows7 but for one critical issue.
    I have a page that issues a query to a web service and is able to display the results in a table. The table rows have links to call a managed bean to prepare then uses an Action to display the results in a new form page. The two pages are in an unbounded task flow. When I click on the link I don't see any debug messages from the bean and don't see the Form page but I see in the logs:
    <Warning> <Socket> <BEA-000449> <Closing socket as no data read from it on 127.0.0.1:49,319 during the configured idle timeout of 5 secs>
    I never had such issue with XP. (note I used the same Jdev 11.1.1.5 software for both)
    Also I have the same application running on a Linx server and when I tested to click on the link from the result table also I never see the Form page when using Windows7 but works fine with XP !?
    Can we use Windows 7 with ADF and WebCenter applications? This critical since my client users are planning to upgrade to Windows7.
    Is there a special configurations to resolve such issue and others that I still didn't test.
    Thanks

    Update,
    I was using IE 9 on windows7 and IE 8 on XP. I now tested with Firefox 64-bit, which is named Namoroka since that was the 64-bit version I found, and I didn't have such issue, surpised.
    My client must use IE since we also have Siebel which uses ActiveX and many government agencies are certified on IE.
    (Note: when using Namoroka, I keep getting a popup when move from one page to another that: "You are using an unsupported browser. The supported browsers are Interner Explorer 7 and higher, Firefox 2.0.0.2 and higher, Safari 3.1.2 and higher, and Google Chrome 1.0 or higher. )
    From what I see now can't upgrade to windows7, but I did see that many are using it. So please help in what you already solved this issue.
    Thanks

  • Reg. Socket Channel Write Method

    Hi,
    We have the following method to write into the socket channel.
         private void write(SelectionKey key)
              SocketChannel channel = (SocketChannel) key.channel();
              try
                   channel.write(writeBuffer);
                   key.interestOps(SelectionKey.OP_READ);
              catch (IOException ioEx)
                   LogUtility.log(Level.SEVERE, ioEx);
    My doubt is, in case of any network related issues and network goes down, how to trap those exception. In those cases, i need to re-establish the connection again to the remote host.
    I tried to check, whether channel.isConnected b4 writing, but the doc says this will return false if the connect operation is never fired.
    It will be helpful for me, if some one gimme an idea to proceed on this.
    Best Regards,
    K.Sathishkumar

    If you get any IOException or SocketException other than a SocketTimeoutException when doing I/O to a socket or SocketChannel you must close the socket/channel. It is of no further use. What else you do depends on the application - log it, maybe try to re-establish the connection if you are a client, forget about it if you are a server.
    BTW:
    We have the following method to write into the socket channel.
    private void write(SelectionKey key)
    SocketChannel channel = (SocketChannel) key.channel();
    try
    channel.write(writeBuffer);
    key.interestOps(SelectionKey.OP_READ);This is not valid. You shouldn't throw away the result of the write and just assume the data got written as you are doing here. You should do something like this:
    try
      // assuming the buffer is already flipped
      int count;
      while (writeBuffer.hasRemaining() && (count = channel.write(writeBuffer)) > 0)
      if (count == 0)
        key.interestOps(SelectionKey.OP_WRITE);
      else
        key.interestOps(SelectionKey.OP_READ);
    catch (IOException ioEx)
      LogUtility.log(Level.SEVERE, ioEx);
      try
        channel.close();
      catch (IOException ioEx2)
        LogUtility.log(Level.SEVERE, ioEx2);
    // ...}

  • How do I use my macbook pro lid closed

    How do I use my macbook pro lid closed?

    Well what i'm trying to do is keep file sharing on while macBook is closed so i can access files through "newtwok" (Back to my mac) with my imac...
    Ideally i would then control my macBook with screen sharing on my imac while the MacBook is stored behind my iMac...
    Somehow it worked before but now it stopped...and everytime i close the lid ..mac book pro goes black screen and completly disconnects from the newtwork...
    Everything works fine with lid open..
    I am trying to do this because i have a new imac with thunderbold and an older macbook pro with mini display port..and as you might already know...you canot connect these thow devices using thunderbolt cable...which really *****....there is also no adaport enabling this...and i really dont need to buy another mac book that just has one more hole in it >.<
    Anyway..hope there is a solution somewhere to keep file sharing going while lid down..
    regards remo

  • Need sql query to find out same item is used in open po and closed po

    Hi Experts,
    I have an requirement is that, i need to find out the item is used in open po and closed po.
      example: A is the item is used in closed PO and Open PO.
      i need to write down the scripts how many same items is used in open po and closed po.
    if any sql script is there please share.
    Please let us know if any concerns.
    Thanks
    bmn

    Hi
    Please try below query
    select
    distinct c.segment1
    from
    po_lines_all a,
    po_line_locations_all b,
    mtl_system_items_b c
    where
    a.po_line_id= b.po_line_id
    and a.item_id=c.inventory_item_id
    and b.closed_code='OPEN'
    and a.item_id in ( select 
    item_id
    from
    po_lines_all d,
    po_line_locations_all e,
    mtl_system_items_b f
    where
    d.po_line_id= e.po_line_id
    and d.item_id=f.inventory_item_id
    and e.closed_code in ('CLOSED','FINALLY CLOSED','CLOSED FOR INVOICE','CLOSED FOR RECEIVING'));

  • Need to use only one sender and receiver communication channel.

    Hello Experts.
    I have a scenario where in I have to use only one sender and receiver communication channel to push files from different source directories to different receiver directories.
    For Eg;
    Sender                              
    D://dir1/file1 --->                  E://dir1/File1
    F://dir2/file2 ---->                 G://dir2/file2
    H://dir3/file3----->                 I://dir3/file3.
    Can this be achieved by using pass through scenario?
    Please let me know if the requirement is not clear.     
    Thanks in advance.
    Advit Ramesh

    Hi Advit,
    I think it is possible. You have to use the Advanced Selection for Source file in the sender channel to define multiple files to be picked up. Also, the Dynamic configuration must also be enabled and used in the mapping so you can manipulate the target directory and target file name based on your source files.
    For Polling from multiple directories:
    http://wiki.scn.sap.com/wiki/display/XI/File+Sender+Adapter+-+Polling+Multiple+Directories
    Dynamic Configuration:
    Dynamic file name and directory in Receiver File Adapter - summary of possibilities - Process Integration - SCN Wiki

Maybe you are looking for

  • Import po a/c key

    hi friends which account key is used to post insurance condition condition type zin% and zinv is it fr1 or fr2 in case of import po. fr1 is custom clearing and fr2 is custom provision. points will be rewarded k.chhikara

  • Unzipping difficulty

    I'm using an iMac with OS X (v 10.8.5) The download function malfunctioned a few days ago.  Now when zipped files are downloaded, I am unable to unzip them by clicking on the file.  I'm using the download function in Safari as a work-around, but that

  • How to call an HTMl page using URL in OAF?

    Hi, There is a page that has a toolbar. There we have to provide a help menu in which we need to display a customized html page. Therefore, we need to set the URL property in such a way that it should map to the path where this HTML file is located.

  • FTP in Data Services

    Dear gurus, I am not able to extract data from FTP on dataservices. I am giving my FTP xxx.xxx.xxx.xxx in the Host. The UserID and the Password. Now i am not able to access the file still. Can you please guide me how to use FTP in Data Services. Rega

  • Delete services folder using Batch input

    Hi, I want to delete a services folder in ME32K using batch input. When I try to make it, a dump occurred with this error "OBJECTS_OBJREF_NOT_ASSIGNED" CX_SY_REF_IS_INITIALC I tried to find between SAP Notes but I didn't find any solutions. Could you