Showing posts with label edge. Show all posts
Showing posts with label edge. Show all posts

Sunday, February 25, 2018

Edge cross-domain request via HTTPS

Leave a Comment

I'm trying to make an Edge extension, which would communicate with another server than origin of the web page. However the communication seems to fail.

I read about issues with cross-domain requests when origin is external and cross-domain request target is in intranet. So I've exposed the intranet server to the internet. But this didn't help.

I tried to run as simplest fetch() as possible and got this result:

fetch("https://fake.domain.info/api/browser/authenticate/").then((response) => {console.log(response);}).catch((error) => {console.log(error);})

[object Promise]: {}

[object Error]: {description: "Failed to fetch", message: "Failed to fetch", number: -2147418113}

I checked network traffic in debug window and found out strange record:

Name Protocol Method Result Content type Received Time Initiator https://fake.domain.info/api/browser/authenticate/ HTTPS GET 200 (from cache) 0 s

I don't really understand why "(from cache)" appears. So inspected request with WireShark. What I've found out is this:

61 3.004629 xxx.xxx.xxx.xxx 192.168.124.144 TLSv1.2 501 Server Hello, Certificate, Server Key Exchange, Server Hello Done

62 3.004666 192.168.124.144 xxx.xxx.xxx.xxx TCP 54 51965 → 443 [ACK] Seq=207 Ack=1908 Win=261632 Len=0

...

86 3.010645 192.168.124.144 xxx.xxx.xxx.xxx TCP 54 51965 → 443 [FIN, ACK] Seq=207 Ack=1908 Win=261632 Len=0

87 3.011785 xxx.xxx.xxx.xxx 192.168.124.144 TCP 60 443 → 51965 [ACK] Seq=1908 Ack=208 Win=65536 Len=0

...

89 3.012215 xxx.xxx.xxx.xxx 192.168.124.144 TCP 60 443 → 51965 [RST, ACK] Seq=1908 Ack=208 Win=0 Len=0

I don't understand why the connection is reset right after the TLS handshake. Opening the web page works fine. I've checked it with WireShark and found out first connection is closed same way right after the TLS handshake but new one is created immediately and traffic goes via this one without problems.

I checked server side logs - no issues where registered. As well as no HTTP requests were logged.

When I tried to run same request via plain HTTP it worked fine:

fetch("http://fake.domain.info/api/browser/authenticate/").then((response) => {console.log(response);}).catch((error) => {console.log(error);})

[object Promise]: {}

[object Response]: {body: Object, bodyUsed: false, headers: Object, ok: false, redirected: false...}

HTTP 404 is returned as expected

So I see the problem is related to TLS connection.

Another thing: the problem occurs only when doing it in Edge. When doing it in Firefox, it works fine:

fetch("https://fake.domain.info/api/browser/authenticate/").then((response) => {console.log(response);}).catch((error) => {console.log(error);})

Promise { : "pending" }

Response { type: "basic", url: "https://fake.domain.info/api/brows…", redirected: false, status: 404, ok: false, statusText: "[{"errors":[{"message":"Invalid API…", headers: Headers, bodyUsed: false }

And I checked traffic in WireShark when running request from Firefox - the connection after the TLS handshake isn't closed but the application data is sent right away.

Is it some known Edge behavior and is there any way to fix it? Could it be some server misconfiguration?

0 Answers

Read More

Sunday, June 4, 2017

Visualize 7 million edges in pygraphistry

Leave a Comment

I have large dataset with of about 7 million edges and after an extensive search for methods and tool to visualise this data I came across pygraphistry I am trying to visualize the edges and connection without applying any modeling for now. But this has shows no errors no output for over 6 hours

My working environment is python 3.x anaconda and windows 64 bit

    import pandas     import graphistry      #  "GRAPHISTRY_API_KEY".     graphistry.register(key='key_from_team')      column_names = ['node1', 'node2', 'StartTime', 'EndTime']     logs = pandas.read_csv('Edges.dat', header = None, names = column_names )     logs[:4] # Show the first three rows of the loaded dataframe      '''     logs['StartTime'] = pandas.to_datetime(logs['StartTime'], unit='s')     logs['EndTime'] = pandas.to_datetime(logs['EndTime'], unit='s')     logs[:4]     '''  plotter = graphistry.bind(source='node1', destination='node2')     plotter.plot(logs) 

0 Answers

Read More

Saturday, April 30, 2016

Edge following with camera

Leave a Comment

I want to follow the rightmost edge in the following picture with a line following robot.

source9

I tried simple "thresholding", but unfortunately, it includes the blurry white halo:

posterized9

The reason I threshold is to obtain a clean line from the Sobel edge detector:

edge9

Is there a good algorithm which I can use to isolate this edge/move along this edge? The one I am using currently seems error prone, but it's the best one I've been able to figure out so far.

Note: The edge may curve or be aligned in any direction, but a point on the edge will always lie very close to the center of the image. Here's a video of what I'm trying to do. It doesn't follow the edge after (1:35) properly due to the halo screwing up the thresholding.


Here's another sample:

source6

posterized6

edge6

Here, I floodfill the centermost edge to separate it from the little bump in the bottom right corner:

final6

1 Answers

Answers 1

Simplest method (vertical line)

If you know that your image will have black on the right side of the line, here's a simple method:

1) apply the Sobel operator to find the first derivative in the x direction. The result will be an image that is most negative where your gradient is strongest. (Use a large kernel size to average out the halo effect. You can even apply a Gaussian blur to the image first, to get even more averaging if the 7x7 kernel isn't enough.)

2) For each row of the image, find the index of the minimum (i.e. most negative) value. That's your estimate of line position in that row.

3) Do whatever you want with that. (Maybe take the median of those line positions, on the top half and the bottom half of the image, to get an estimate of 2 points that describe the line.)

Slightly more advanced (arbitrary line)

Use this if you don't know the direction of the line, but you do know that it's straight enough that you can approximate it with a straight line.

1)

dx = cv2.Sobel(grayscaleImg,cv2.cv.CV_32F,1,0,ksize=7) dy = cv2.Sobel(grayscaleImg,cv2.cv.CV_32F,0,1,ksize=7) angle = np.atan2(dy,dx) magnitudeSquared = np.square(dx)+np.square(dy) 

You now have the angle (in radians) and magnitude of the gradient at each point in your image.

2) From here you can use basic numpy operations to find the line: Filter the points to only keep points where magnitudeSquared > some threshold. Then grab the most common angle (np.bincount() is useful for that). Now you know your line's angle.

3) Further filter the points to only keep points that are close to that angle. You now have all the points on your line. Fit a line through the coordinates of those points.

Most advanced and brittle (arbitrary curve)

If you really need to handle a curve, here's one way:

1) Use your method above to threshold the image. Manually tune the threshold until the white/black division happens roughly where you want it. (Probably 127 is not the right threshold. But if your lighting conditions are consistent, you might be able to find a threshold that works. Confirm it works across multiple images.)

2) Use OpenCV's findcontours() to fit a curve to the white/black boundary. If it's too choppy, use approxPolyDP() to simplify it.

Read More