Web HTTP proxy using IO Non blocking

Solved thank you...

customer. Register (selector, SelectionKey.OP_READ
| SelectionKey.OP_WRITE);

OP_READ only at this stage. OP_WRITE is always 'ready' unless the socket buffer is full, so your selector will turn only. Do not save OP_WRITE until you have something to write.

ByteBuffer bferClient = ByteBuffer.allocate (4096);

You do this each time around the loop, and you don't even know if the key is still readable. Do it when you accept a connection, and then save it as the essential accessory for this channel.

client.configureBlocking (false);

It is already in non-blocking mode. Why you do it again?

try {}
If ((bytesRead = client.read (bferClient))! = - 1) {}

bferClient.flip ();
String msgFromClient = new String (bferClient.array ());

new String (bferClient.array (), 0, bferClient.limit () - 1), but you're assuming that you've got a complete command here. You do not have. This is another reason why you need a ByteBuffer by channel.

Channel.Connect (SocketAddress);

You should do it in non-blocking mode, save the channel for OP_CONNECT and leave the select loop to take care to complete the connection.

Channel.Write (bferClient);

The incoming command is CONNECT. You do not write than upstream.

If (!) » ». {Equals (msgFromClient.Trim ()))}
int bytesReadServer;
response from Byte [] = new ubyte [4096];
try {}
ByteBuffer bufferNIO = ByteBuffer.allocateDirect (1024);
While ((channel.read (bufferNIO))! = - 1) {}
bufferNIO.flip ();
customer. Write (bufferNIO);
bufferNIO.clear ();
}

And you don't do that here. Register the new channel for OP_CONNECT, then when you get finishConnect() and then save it to OP_READ, and moving forward in your select loop. You also need to associate the channel with the channel that read you the CONNECTION since. If you really need an object of attachment key for the original channel that contains the buffer of bytes and the channel upstream; Similarly, the channel upstream must a key attachment that contains sound buffer and its channel downstream. The effect of making all this stuff here rather than around the loop of selection is that you're never going back to the loop of the selection: you manage what a customer here in blocking mode, until the connection is dropped. Completely wrong.

} catch (IOException e) {}

Hang up. If bytesRead a-1, you must close the channel.

e.printStackTrace ();

And if you get an IOException here you must also close the channel.

If (channel! = null) {}
try {}
Channel.Close ();

This is a really strange place to close this channel.

When you get this fixed upward, your zip code and I will tell you how to handle the OP_WRITE.

Tags: Java

Similar Questions

  • Expose the service as a Web service proxy using the sb Protocol

    Hello world.

    My team and I worked on a project of integration between multiple applications. So we created all the OSB projects necessary to connect applications and now I'm working on a web application that reads several newspapers who leave these integrations in the database in order to watch what happens when they are executed. Right now, I need my web application to be able to reprocess or retry messages that present a problem or are in an error state.

    To this end, we have developed a proxy with a sb protocol that allow us to communicate with other services dynamic proxy just in him passing the name of the proxy, its functioning and the message of the body. And finally, here's my question for you guys.

    How do I expose this last proxy (with the sb Protocol) as a web service so I can consume it for action to reprocess/try again?

    Thank you.

    Don't think that you need a Proxy service with SB Protocol at all. As I understand it, your process will be like this:

    1 web app bed DB logs to see what documents need to be submitted again

    2. web App must call OSB to resubmit the log message to correct the proxy.

    What you can do is create a WSDL based proxy HTTP to OSB for a new presentation, Web application must call this proxy and passes the body, the name of the target (full path) service, target service type HTTP (Proxy or Business), target the operation name (optional, like e-mail or type XML services everything will not associated with surgery). You can add a dynamic routing node in the HTTP proxy that calls the proxy target based on information coming from the Web App.

    SB Protocol should be used in a Proxy service if you want to call a Proxy deployed in a single domain of OSB on another area of OSB or composites Oracle SOA. Here, the consumer will be the Web application, so it needs to be a HTTP proxy and not SB.

    P.S.: You should also consider sending transport/custom headers as well, not only the body for your new design be more reusable.

  • I want to block access to some Web sites when using firefox, how do I do this?

    I would like to be able to block access to specific Web sites when using Firefox as my browser. How can I do this? Thank you.

    Block / unblock websites with parental control on Firefox

    https://addons.Mozilla.org/en-us/Firefox/addon/BlockSite/

  • How to use a KeyManager custom in SSLSocketChannel non-blocking

    In our existing project I had to replace the SocketChannel non-blocking by SSLSocketChannel no blocking. My implementation of the SSLSocketChannel non-blocking mask all the SSL stuff and can be used as a SocketChannel overall of the project that just use the SSLSocketChannelProvider instead of SocketChannelProvider in one place.

    Now I have a new requirement. Different server-certificate should be used for various IPS on the same SSLServerSocket. The relationship between the IPs and certificates is well known. The first idea was to use a custom KeyManagerDelegate that extends from X509ExtendedKeyManager to select the certificate from the server. The KeyManagerDelegate should delegate calls to a KeyManager obtained by
    KeyManagerFactory.getInstance("NewSunX509").getKeyManagers();
    It works if I use a blocking SSLServerSocket obtained by SSLContext.getServerSocketFactory () .createServerSocket ();

    But the KeyManagerDelegate is never called by the SSLContext if I use my own non blocking SSLServerSocketChannel. Instead of calling my KeyManagerDelegate the SSLEngineImpl throws an Exception
    javax.net.ssl.SSLHandshakeException: no cipher suites in common
         at com.sun.net.ssl.internal.ssl.Handshaker.checkThrown(Handshaker.java:951)
         at com.sun.net.ssl.internal.ssl.SSLEngineImpl.checkTaskThrown(SSLEngineImpl.java:466)
         at com.sun.net.ssl.internal.ssl.SSLEngineImpl.writeAppRecord(SSLEngineImpl.java:1092)
         at com.sun.net.ssl.internal.ssl.SSLEngineImpl.wrap(SSLEngineImpl.java:1064)
         at javax.net.ssl.SSLEngine.wrap(SSLEngine.java:452) 
    The next thing I'm going to try would be to get the SSLContext to use my own SSLSocketChannelProvider as ServerSocketFactory.

    Or I use different SSLContext for each incoming connection, which would break my own design because the server had to waste his time with the construction of new SSLContext. Another possibility is to implement a callback in the ServerSocketChannel to get a new SSLContext for each accepted connection. It would be sure my design but looks like a ugly workaround solution for me and I do not know if it works.

    All the best ideas?

    Thanks Domi

    I just tested this with my SSLSocketChannel and it works like correctly, the KeyManager methods called as expected. You hurt something else ;-) Do not extend X509ExtendedKeyManager to work properly with the engine.

  • WSA certificate for https proxy options

    An intermediate cert from Entrust L1K are recognized by the ASO? When I try to go to a Web site that uses a cert L1K entrust the ASO is blocking the site.

    Date: Wednesday, February 18, 2015 02:36:23 GMT
    User name:
    Source IP: 192.168.201.70
    URL: GET https://.
    Category: Government and law
    Reason: UNRECOGNIZED_ROOT_CERT
    Notification: CERT_INVALID

    WSA is a Entrust cert but not for L1K.

    You might want to export this certificate on your local computer and imported to the proxy HTTPS WSA Custom certificates of trust.

    Normally, I used Firefox and not using WSA as a proxy as the initial connection can get the cert of the remote site and save it locally and import it on the WSA HTTPS cert.

    You can view log HTTPS thus in WSA and set the debug logging level for more details like why is a failure.

    Hope this helps

  • Cannot access the Web http sites

    Since yesterday, I have not been able to access any site that begins with http://, only Web sites that begin with https://. I do not download anything anything beforehand, it was working fine in the morning, but I came home in the afternoon and it did not work. No one else has used the computer. I can't go to these Web sites on firefox, safari or google chrome. I tried to unplug my router, clear the cache, history and cookies from my browser, resetting the computer, update the computer and the browser, use OpenDNS, but nothing works. I installed HTTPS Everywhere, that allows me to go on a site that wouldn't work before, but most of the websites that I use usually will not work.

    I'm lost for what to do, so any help would be appreciated.

     / System Preferences / network / advanced / proxies / then deselect "proxy web http.

  • reading non-blocking

    Hello

    I'm trying to implement a lock read along the lines of peekdata() in matlab http://www.mathworks.de/access/helpdesk/help/toolbox/daq/index.html?/access/helpdesk/help/toolbox/da...

    I found I can do readings not blocked from using the reading + http://forums.ni.com/ni/board/message?board.id=230&thread.id=2862 reminders

    Is there another way to get non-blocking reads?   The reason is that if the above, I've implemented the matlab Matlab mex interface calls the file (mex) C and I do read (must wait the trigger occurs) before returning from the C file (aka it becomes again blocking). So that callbacks are not really useful if the thought in a single thread passing that matlab works.

    Thanks for reading.

    The way in which the driver is written is to block on a reading DAQmx.  In a single threaded method will always call blocking as I know.

  • Non-blocking with Perl VI API monitor task

    I am writing a perl script that needs...

    1. Suspend a virtual machine
    2. Do 'some other supervision' while the virtual machine in the suspension process
    3. Make sure that the task is complete suspension

    I was looking at the documentation for the API, but also the code example and there are many examples which have helped me understand how to do #1 and to some extent #3 by calling SuspendVM() on the managed virtual computer object (see my sample code "Option 1").  But it is not perfect for #3 and does not allow me to do #2 at all.  API documentation leads me to believe that I should be able to use SuspendVM_Task() on the virtual computer object for a task monitor-a measure of object (see 'Option 2') in my sample code.)

    However, I can't understand how to use this object task to track progress.  I think it must be something like "Block monitor" in my code, but that doesn't seem to work.  Watching a dump of the task object, "info" property seems to not even be there.  I can bless the object to its class real slot (instead of the generic ManagedObjectReference, it starts as), but then the property of the info is just empty.

    I know I probably stopped next to a simple shade of perlOO/perl/perlReference, but can not find where I'm going wrong... any help out there?

    Output of dump of the object of the task

    ========================

    $VAR1 = bless ({}
    'value' = > ' haTask-1808 - vim.VirtualMachine.suspend - 1852795401',
    'type' = > 'task '.
    (}, "ManagedObjectReference");

    Code example

    ==========

    #! / usr/bin/perl - w

    use strict;

    use warnings;

    Use Data::Dumper;

    use VMware::VIRuntime;

    past #./vmSuspend.pl--mot, username - XXXX XXXX - Server XXX.XXX.XXX. XXX - vmname XXXX

    My % opts =)

    'vmname' = > {}

    Type = > "s =",

    help = > "the name of the virtual machine.

    required = > 1,

    },

    'filter' = > {}

    Type = > "s =",

    help = > 'filter to select corresponding virtual machines. "

    required = > 0,

    },

    );

    OPTS::add_options (%OPTS);

    OPTS::parse();

    OPTS::Validate();

    Util::Connect();

    My $retval = 0;

    my $name = Opts::get_option ('vmname');

    My $vm_view = Vim::find_entity_view (view_type = > 'VirtualMachine',)

    filter = > {'name' = > $name});

    my $state = $vm_view-> run - > powerState-> val;

    Print "$name is $state\n";

    # Option 1 - blocking

    # $vm_view-> SuspendVM();

    # Option 2 - non-blocking

    My $suspendTask = $vm_view-> SuspendVM_Task();

    print Dumper ($suspendTask);

    # Block monitor

    # everything in ($suspendTask-> info-> status-> val eq 'running' | $suspendTask-> info-> status-> val eq 'pending') {}

    # < < some other surveillance > >

    #}

    $vm_view-> update_view_data();

    $state = $vm_view-> run - > powerState-> val;

    Print "$name is $state\n";

    Take a look at this script for example: http://communities.vmware.com/docs/DOC-10269 there is a method in there called getStatus() that shows you a task queue is complete before continuing. You are on the right track, but must do a few more things to get the display of the task and make sure that you update the view after sleep/wait and then check again.

  • Add headers to a Web Service Proxy

    Hi all

    I am trying to use a web service via a web service proxy in a common library of java, as part of a validation method. I use JDev 11.1.1.5.

    The question that I have is that the web service requires two custom headers. I created a CustomSOAPProvider class that extends the internal ADF SOAP class provider to add extra headers, which works when I implement the WS as a data control. I recreated it as a web service proxy, but I'm not sure whether to refer to the current SOAP message and edit it with extra headers in a java class? I call the web service successfully, and I get a response "unauthorized".

    Any help would be appreciated!

    Thanks in advance,
    Aaron

    I got it...

    Card reqCtx =
    ((BindingProvider) iditInterface) .getRequestContext ();
    Card reqHttpHeader =
    ReqCtx.get (MessageContext.HTTP_REQUEST_HEADERS) (map);
    If (null == reqHttpHeader) {}
    reqHttpHeader = new Hashtable ();
    }
    The list header1 = new ArrayList();
    Header1.Add ("[Header1-value]");
    reqHttpHeader.put ("[header1name]" header1);

    Tete2 list = new ArrayList();
    Header2. Add("[header2-value]");
    reqHttpHeader.put ("[header2name]",-tete2).

    reqCtx.put (MessageContext.HTTP_REQUEST_HEADERS, reqHttpHeader);

    I used the code above to add HTTP headers, before calling the Web service interface.

  • Cannot create the web service proxy in jdeveloper

    Hi all

    I'm unable to create a proxy web service by using the URL of the web service (https://domains.live.com/service/managedomain2.asmx?wsdl). I get an error saying "no WSDL not could be found. I am able to open the same URL in the browser. As the web service is secured by SSL, do I need to add anything on the jdeveloper to access this web service? Help, please


    Note: The web service must be called on https

    -MJ

    Hello

    The parameters are the proxy settings that are necessary for JDeveloper to connect to external sites - other than those available in the internal intranet.
    To connect to internet/external sites, you must have for this parameter. Here, as you try to connect to the external site - Windows live, you will need these settings.

    Thank you
    Nini

  • Problem with creating Web Service Client using Oracle JDeveloper

    Hi all

    I am trying to create a Web Service Client using Oracle JDeveloper. The property of the compiler of the project I updated JRE 1.4

    When I run the web service client, he gives me a lot of errors saying:
    ' Error (32.2): annotations are not supported in - source 1.4'

    I wonder why JDeveloper uses annotations even after that I set the compiler property to 1.4

    I'm following this link to create the Web service client:
    http://www.Oracle.com/technetwork/developer-tools/forms/WebServices-forms-11g-094111.html

    Any help in this regard would be greatly appreciated.

    Thank you
    Scott.

    Scott, when you run the proxy Web service in JDeveloper, you will see a bunch of jars listed in the classpath in the Journal JDeveloper window.
    All of these classes must be in the classpath of your server when the class is deployed there.
    Note that by default, I don't think they are going to be included in the JAR that you build for the proxy when you deploy.

  • Web service proxy generation: Ant?

    We are currently working with the new "web service proxy' of jdeveloper.
    Since we have tons of services and do not want to manually, is it possible to make an Ant target to clean up the directory and regenerate their?

    Thank you.

    Hi JGeerts and Koen

    Perhaps this sample application can help:
    http://verveja.footsteps.be/~verveja/files/Oracle/AntWSAGenProxyApp-v0.01.zip

    It contains the resulting code of popup "generate Web Service Proxy..." menu option "on the WeatherWS.wsdl, using JDeveloper 10.1.3.4.0.

    It has a file build.xml with a 'clean .generated-proxy-code' and a target of "wsa.genProxy.WeatherWS".
    The WeatherWSTestTool class in the sample application works with both, JDeveloper and Ant, generated proxies.

    Here is the content of the build.xml file:

    
    
         
    
         
              
                   
              
         
    
         
              
                   
                   
                   
                   
                   
                   
                   
                   
                   
              
         
    
    

    success
    Jan Vervecken

  • How can I configure Mozilla to accept connections on port "The World Wide Web (HTTP) service"?

    When you try to embed a video in PowerPoint 2013, the "Sorry we are having some problems of temporary service" message.

    In research on the problem to Microsoft. com, the following message is received: Mozilla is not configured to accept connections on port "The World Wide Web (HTTP) service."

    Hmm... PowerPoint must use Windows to connect to the internet and not Firefox.

    What method do you use?

    (1) insert > video > video online

    Apparently, there was an update this month that allows this, as described in this message of support (see the top of page answer right after the question): embedding video in powerpoint 2013 - Microsoft YouTube community online

    Here's how it should work after the update: Insert or link to a video on YouTube - PowerPoint

    (2) developer > control > Shockwave Flash Object

    As documented on other sites, such as: https://www2.palomar.edu/pages/atrc/2013/09/17/how-to-embed-youtube-video-in-powerpoint-2013/

  • Creation of SCOM Web Service Proxy OMCF

    I am referring to the Sub SCOM documentation to create an OMCF web service proxy.

    https://msdn.Microsoft.com/en-us/library/hh328977(d=printer).aspx

    When I execute a command:

    Svcutil /language:c# /config:app.config http://localhost:6272/ConnectorFramework?svc
    
       --> Replaced localhost with the actual IP address where my SCOM is installedI get below WS- MetaDataexchange error message. I made sure the data access service is up and running in windows services.Can anybody suggest what could be the issue here? Firewall or the port I am accessing is wrong or do I need to configure any service for this to work? Error: Cannot obtain Metadata from http://10.50.1.153:6272/ConnectorFramework?svc
    
    If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address.  For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455.
    
    WS-Metadata Exchange Error    URI: http://10.50.1.153:6272/ConnectorFramework?svc
    
        Metadata contains a reference that cannot be resolved: 'http://10.50.1.153:6272/ConnectorFramework?svc'.
    
        Could not connect to http://10.50.1.153:6272/ConnectorFramework?svc. TCP error code 10061: No connection could be made because the target machine actively refused it 10.50.1.153:6272.
    
        Unable to connect to the remote server
    
        No connection could be made because the target machine actively refused it 10.50.1.153:6272
    
    HTTP GET Error    URI: http://10.50.1.153:6272/ConnectorFramework?svc
    
        There was an error downloading 'http://10.50.1.153:6272/ConnectorFramework?svc'.
    
        Unable to connect to the remote server
    
        No connection could be made because the target machine actively refused it 10.50.1.153:6272
    
    If you would like more help, type "svcutil /?"
    
    C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin>
    
    This issue is beyond the scope of this site (for consumers) and to be sure, you get the best (and fastest) reply, we have to ask either on Technet (for IT Pro) or MSDN (for developers)

    If you give us a link to the new thread we can point to some resources it
  • Unlocked blackBerry Smartphones Software Update has not received the AT &amp; T brand PRIVATE when you use a non - AT &amp; T SIM card

    Dear whom it may concern,

    I saw one of the support forum of Blackberry Web site on "software update, not received the AT & T unlocked brand PRIVATE when you use a non - AT & T SIM card". How can I receive the OTA update in the notification bar?

    Now, my OS is Mashmallow 6.01 build No.. AAF355 (June 1, 2016) or do I have to update (auto loadder) my Priv to AAG873 in order to get the direct OTA from Blackberry in the future.

    Thank you

    Good questions. I can speculate only at this stage. I guess that since it is updated by BB, they use a revision update for all devices to facilitate management. AT & T updates their different, since they have different methods of approval (Note T-mobile even updated as unlocked devices). Unless you want to get specific version of AT & T that could fix something that the other version does not work, I'd wait for the OTA. I did three refills of OS because I couldn't OTA of AT & T, and they take a lot of time. Take the time then to restore and to reconfigure all the settings you had before. Not funny.

    To be more precise questions. Depends on you, but for me, would be updated via OTA only now that it's available. Yes, if you want auto charger, use AT & t. even as before, wait for OTA, unless you have a specific automotive need load the operating system.

Maybe you are looking for

  • Apple TV 4 Siri stops working

    My new Apple TV was working fine until about a month in and all of a sudden I find that my Siri stops responding intermittently. I press and hold down the button and order and I can see it my voice, but not obey or responds that he is just there wait

  • I'm very frustrated by the complete impossibility to organize files in Safari.

    I'm very frustrated by the complete impossibility to organize files in Safari. It would be nice if Apple has simply created bookmarks in Safari roughly the same work as folders in the Finder.  A simple feature, you would think but apparently a glarin

  • Re: My laptop makes a lot of noise

    Hi, my name is Akram, I come from the United States of America. I got this Toshiba laptop last year, I have all the details it s bought in the UK and sold in Saudi Arabia.Recently, since a month since my laptop makes a lot of noise can be the fan or

  • Portege M700 - protection of HARD drive problem

    Hello world I searched the net for a full day now try to find answers to this.Note, I am an accountant and not a computer geek. I have a laptop Portege M700. I am updating from Vista to Win7. Here's the problem:-Initially tried to uninstall Toshiba H

  • Out of bounds last

    I just ran a big update on my desktop for Windows XP.  I think it should have updated me service pack 1 to service pack 3.  Now, when I start the computer, instead of my desktop, I get a blue box that says out of bandwidth. Lower than there a banner