I was messing around with a UPnP library which I'll be using for a game server. I came to a point where I had to make my addPortMapping-function fail somehow, but since I don't have direct access to the router, I can't turn off UPnP in order to make it fail.
What I did try, in order to make the function fail (which ultimately it didn't), was to try to add a port mapping to port -1.
Now I have the problem of not being able to remove a port mapping from the router to my computer on port -1...
As ports can't be < 1, this confuses me.
Is this a known problem?
WANIPConnection:2 specification defines both externalPort and internalPort as "ui2" so they're unsigned integers 0-65535 (internalPort also can't be 0, which is used as wildcard for externalPort). If an implementation accepts -1 it's just broken: So this is not a known problem but a bug in your router. Buggy UPnP-IGD routers in general are a known problem so this is not a surprise.
Related
Recently, I try hard to use OpenDDS SSL in WAN network. But All my attempts to failed.
This is caused by the inability to find different hosts.
I realized one thing. OpenDDS security should use rtps_discovery, not InfoRepo, and it is difficult to find two hosts in different subnetworks via rtps_discovery.
I have been searched about discovering host by rtps_discovery option from SourceForge, github, and stackoverflow. But, No one successed in this manner.
https://sourceforge.net/p/opendds/mailman/message/36320180/
https://github.com/objectcomputing/OpenDDS/issues/854
So, my question is how to find the host using rtps_discovery on the WAN network.
here is my ini file:
[common]
DCPSGlobalTransportConfig=$file
DCPSSecurity=1
[domain/4]
DiscoveryConfig=uni_rtps
[rtps_discovery/uni_rtps]
SedpMulticast=0
ResendPeriod=2
SpdpSendAddrs=publisher's IP:56789
[transport/the_rtps_transport]
transport_type=rtps_udp
use_multicast=0
local_address=subscriber's IP:55555
please give me some ideas to solve this problem
It is really impossible to discover hosts in different subnetworks via rtps_discovery??
I'm finally success to communicate using rtps discovery!
It just SpdpSendAddrs attribute set 8410 port.
like this:
[common]
DCPSGlobalTransportConfig=$file
DCPSSecurity=1
[domain/4]
DiscoveryConfig=uni_rtps
[rtps_discovery/uni_rtps]
SedpMulticast=0
ResendPeriod=2
SpdpSendAddrs=subscriber's IP:8410
[transport/the_rtps_transport]
transport_type=rtps_udp
use_multicast=0
But, new question is that how to confirm this security function work properly??
When I capture packet by wireshrk, I can see the data not encryped.
I used OpenDDS Messenger security example.
I'm creating an application that uses NSNetService to publish a server, and I've come across the NSNetServiceListenForConnections option that can be used in OS X 10.9 with the publishWithOptions: method. This new options is highlighted in the "What's New in OS X 10.9" page provided by Apple. It states If you send the NSNetServiceListenForConnections option flag in the options value passed to publishWithOptions:, OS X automatically handles all of the connection management for you, however, I don't see how this a new behavior? I currently just call the publish method and wait for the ServerAcceptCallBack, which is set by the CFSocketCreate method. I doesn't seem to make this any easier?
I'm following some of Apple's code from the CocoaEcho example, which gets a port and opens a CFSocket. I know you can pass 0 as the port parameter for the initWithDomain: name: port: method, but that chooses a "random" port, and I'm guessing that that's not a 100% safe thing to do. I thought that NSNetServiceListenForConnections might have something to do with that, but going by the description, it doesn't.
So to my actual question, after all the rambling:
What does the NSNetServiceListenForConnections option actually do, and (why) should I use it?
Side question: If I should use it, how do I check for availability? I've been told to use if (&NSNetServiceListenForConnections != NULL), but NSNetServiceListenForConnections is an NSUInteger so I can't get the address (via &)
With this option, you don't have to open or manage the sockets at all (i.e. no calling CFSocketCreate). It creates the socket for you. Although I'm finding in 10.9.2 it isn't closing the socket properly if you call stop on the netService, but I'm still investigating. (It did seem to be closing them in 10.9.0 and 10.9.1). The socket seems to stay open until you quit the app.
I have a problem in delivering sensor data to the xively API via an Arduino Uno v3 and a Sparkfun WiFly shield. The problem is not in the hardware, or in the WiFly shield library since I can deliver the data to the Paraimpu server just fine.
The most fundamental problem is that the xively library will not work with the sparkfun WiFly library. The relevant declarations (suggested by xively in the documentation) are:
WiFlyClient client;
XivelyClient xivelyclient(client);
this will not work since the WiFlyClient declaration expects a server and port, hence I modified this to:
byte server[] = {173,203,98,29}; //api.xively.com IP address
WiFlyClient client(server,80);
XivelyClient xivelyclient(client);
This gives me an error on compilation of :
Xively_sketch2_aug20a:60: error: no matching function for call to 'XivelyClient::XivelyClient(WiFlyClient&)'
/Users/paultravers/Documents/Arduino/libraries/xively/XivelyClient.h:11: note: candidates are: XivelyClient::XivelyClient(Client&)
/Users/paultravers/Documents/Arduino/libraries/xively/XivelyClient.h:9: note: XivelyClient::XivelyClient(const XivelyClient&)
At this point I am stuck, and my attempts to modify the various libraries to try to reconcile this issue have come to no avail - mostly because it is above my skill level and I really don't know what I am doing.
To get round this, I have written the code to build the put request and send that to the API, using the template of the code that runs successfully to send data to Paraimpu.
I open a connection (either to api.xively.com or to 173.203.98.29; it makes no difference at this stage) and send the following :
PUT /v2/feeds/<feed ID redacted>.json
Host: api.xively.com
Content-Type: application/json
User-Agent : Xively-Arduino-Lib/1.0
X-ApiKey: < API key redacted >
Content-Length: 197
{"version":"1.0.0","datastreams" : [{"id":"TEMPERATURE_CHANNEL" , "current_value" : "29.00"},{"id":"LIGHT_SENSOR_CHANNEL","current_value":"541.00"},{"id":"ALARM_CHANNEL","current_value":"0.00"}]}
Terminating with a blank line.
Needless to say I have set up channels in xively with those names. But this does not work - I don't get the expected return, and the channels don't update. If I read the returning input on the connection it is just a long string of numbers. Can anyone see anything wrong in the format of this request?
i might take a look at WiFlyClient's documentation...maybe you need to set the port/etc in some other way...than extend WiFlyClient
class WiFlyClient2 : public WiFlyClient {
WiFlyClient2(int[] ip,int port) : WiFlyClient() {
//setup up your parent by calling it's functions here
}
}
then it should work like:
byte server[] = {173,203,98,29}; //api.xively.com IP address
WiFlyClient client(server,80);
XivelyClient xivelyclient(client);
note: i never use wifly/etc, i just use arduino...and i run into troubles like this too :)
I don't have a WiFly shield to test with. But as you said in your comment to Zoltan, I don't think that the WiFly client works in the same way that the Arduino Ethernet or Wifi do. This means that the Xively library likely does not work with the WiFly client.
This means that your approach of writing your own HTTP request is probably the way to go. I looked through your request and it looks exactly correct to me. Does anything show up in the Xively Workbench Request Log when you send the request?
One thing you could try is to use the CSV format instead. This can be better for testing since you avoid the possibility of a minor JSON error causing your entire request to not work. To do this change your .json to .csv and then simply make your body a comma separated list of datastream,value. Your body should look something like this:
TEMPERATURE_CHANNEL,29.00
LIGHT_SENSOR_CHANNEL,541.00
ALARM_CHANNEL,0.00
If this does not work it would be helpful if you could post what the return is, that would help us help you. Good luck!
One thing I noticed in your code is that you don't send the HTTP version in your request.
You should try sending:
PUT /v2/feeds/<feed ID redacted>.json HTTP/1.1
I was getting 405 errors when writing to Xively because I incorrectly had HTTP/1.0 as the version in my put requests.
There's also an example from SparkFun's WiFly library that shows writing to Thingspeak which is helpful to make sure you're using the WiFlyClient instance correctly.
I am sending a big endian byte array to a UDP host and all works well, but I need to incorporate proxies into the mix.
From what I've found (or haven't found) there is no straight forward way to use anonymous proxies (or even Socks4/5) with UdpClient. Can anyone help?
You should use System.Net.HttpWebRequest.Proxy for the proxy. Check the MSDN code snippet link for more information. I had a similar problem and this helped.
When using the getaddrinfo method, I'm providing an IP address and the port number. I'm getting a linked list in the out variable. It works fine. But I have a conceptual doubt here. When i am giving both the IP address and port, how is it there are so many possible sockets returned? Shouldnt there be only one?
From the getaddrinfo man page:
There are several reasons why the linked list may have more than one
addrinfo structure, including: the network host is multihomed,
accessible over multiple protocols (e.g. both AF_INET and AF_INET6);
or the same service is available from multiple socket types (one
SOCK_STREAM address and another SOCK_DGRAM address, for example).
Normally, the application should try using the addresses in the order
in which they are returned. The sorting function used within
getaddrinfo() is defined in RFC 3484; the order can be tweaked for a
particular system by editing /etc/gai.conf (available since glibc
2.5).